Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (27 sloc) 1.44 KB
layout language permalink command related_commands
api-command
Python
api/python/outer_join/
outer_join
eq_join inner_join zip
eq_join/
inner_join/
zip/

Command syntax

{% apibody %} sequence.outer_join(other_sequence, predicate_function) → stream array.outer_join(other_sequence, predicate_function) → array {% endapibody %}

Description

Returns a left outer join of two sequences. The returned sequence represents a union of the left-hand sequence and the right-hand sequence: all documents in the left-hand sequence will be returned, each matched with a document in the right-hand sequence if one satisfies the predicate condition. In most cases, you will want to follow the join with zip to combine the left and right results.

{% infobox %} Note that outer_join is slower and much less efficient than using concat_map with get_all. You should avoid using outer_join in commands when possible. {% endinfobox %}

Example: Return a list of all Marvel heroes, paired with any DC heroes who could beat them in a fight.

r.table('marvel').outer_join(r.table('dc'),
  lambda marvel_row, dc_row: marvel_row['strength'] < dc_row['strength']
).zip().run(conn)

(Compare this to an inner_join with the same inputs and predicate, which would return a list only of the matchups in which the DC hero has the higher strength.)

You can’t perform that action at this time.