leftjoinΒΆ

The leftjoin command appends the columns of the stream specified in the argument to the columns of its input stream by evaluating the join-condition. Joined columns in the records where join-condition evaluates to false will be set to NULL:

leftjoin( {'@'stream_ref | '@' '[' results_file ']' | '@' '[' script_file ']'}
      [AS alias] ON join_condition )

join_condition:
field_from_left_side_data = field_from_right_side_data [ {AND | OR} boolean_expr ,... ]

Note

When the field names for joining are same then the join condition can be expressed simply as field name: leftjoin(@stream_ref ON field_name)

Note

Assigning alias is optional. When it is omitted then:

  • default aliases are assigned to the left and right streams: left and right respectively.
  • fields with matching names in joined sets will be renamed by prepending left_ or right_ to field name respectively
  • fields with different names remain the same in the resultset

Example:

1
2
3
4
5
@strm=dual(count:5, offset:3) | select(sequence:i, mac:m);

dual(count:5, offset:0) | select(sequence:i, ip)
| leftjoin(@strm on left.sequence = right.sequence)
;
where in :
  1. line 1 we declare a stream of 5 records starting from 3, with sequence and mac-address fields
  2. line 3 we generate stream of 5 records starting from 0, with sequence and ip-address fields
  3. line 5 performs left join the input stream with @strm