ModifyPlan.prototype.joinFullOuter( rightPlan as String, [keys as ondef | ondef[]], [condition as xs.boolean] ) as ModifyPlan
This method yields one output row set with the rows from an inner join as well as the other rows from both the left and right row sets.
The join performs natural joins between columns with the same identifiers. To prevent inadvertent natural joins, specify a different qualifier for the left or right columns or use different column names for the left and right columns.
Parameters | |
---|---|
rightPlan | The row set from the right view. |
keys | Equality condition(s) expressed using one or more calls to the function op.on. These conditions are used to compare the left and right rows. |
condition | A boolean expression used to compare the left and right rows. See Boolean Expression Functions for the list of functions used to build boolean expressions. |
keys
and condition
are used to specify
the join condition. keys
allows for a simplified syntax
for equality join condition. While condition
allows for
inequality and complex join conditions.
This method combines keys
and condition
using an AND operator such that:
view .joinFullOuter( otherView, op.on(view.col('column1'), otherView.col('column2')), op.ge(view.col('column3'), otherView.col('column4')) )is the same as
view .joinFullOuter( otherView, null, op.and( op.eq(view.col('column1'), otherView.col('column2')), op.ge(view.col('column3'), otherView.col('column4')) ) )
joinFullOuter
is a method of the following classes:
// Find the employees with or without locations and the locations without employees. const op = require('/MarkLogic/optic'); const employees = op.fromView('main', 'employees'); const locations = op.fromView('main', 'locations'); const Plan = employees.joinFullOuter(locations, op.on(employees.col('LocationID'), locations.col('LocationID'))) .orderBy('EmployeeID') Plan.result();
'use strict'; const op = require('/MarkLogic/optic'); const fruits = op.fromLiterals([ {"fruit" : "mango", "count" : 10}, {"fruit" : "apple", "count" : 7}, {"fruit" : "orange", "count" : 9} ]); const orders = op.fromLiterals([ {"flavor" : "apple", "cups" : 5}, {"flavor" : "orange", "cups" : 14} ]); fruits.joinFullOuter( orders, op.on(op.col('fruit'), op.col('flavor')), op.ge(op.col('count'), op.col('cups')) ) .result() /* fruit of 'orange' and 'mango' will pair with flavor of 'null' flavor of 'orange' will pair with fruit of 'null', fruit of 'apple' will pair with flavor of 'apple' */
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.