跳转至

Cross join(交叉连接(Cross join))

Supported in: Batch, Faster

Cross joins left and right dataset inputs together, matching all rows from each side against all rows from the other. The output is the cartesian product of the two datasets.

Transform categories: Join

Declared arguments

  • Condition for columns to select on the left: All columns in the left input schema will be tested to see if they match this condition. If they match, the column will be selected in the output.
    ColumnPredicate
  • Condition for columns to select on the right: All columns in the right input schema will be tested to see if they match this condition. If they match, the column will be selected in the output.
    ColumnPredicate
  • Left dataset: Left dataset to use in join.
    Table
  • Right dataset: Right dataset to use in join.
    Table
  • optional Prefix for columns from right: Prefix to add to all columns on the right hand side.
    Literal\

Examples

Example 1: Base case

Argument values:

  • Condition for columns to select on the left:
    columnNameIsIn(
     columnNames: [tail_number, airline],
    )
  • Condition for columns to select on the right:
    columnNameIsIn(
     columnNames: [home_airport],
    )
  • Left dataset: ri.foundry.main.dataset.left
  • Right dataset: ri.foundry.main.dataset.right
  • Prefix for columns from right: null

Inputs:

ri.foundry.main.dataset.left

tail_number airline miles factor
XB-123 foundry air 124 2
MT-222 new airline 1123 5
PA-452 new air 212 2

ri.foundry.main.dataset.right

tail_number home_airport
XB-123 LHR
MT-222 CPH
KK-452 JFK
JR-201 IAD

Output:

tail_number airline home_airport
XB-123 foundry air LHR
XB-123 foundry air CPH
XB-123 foundry air JFK
XB-123 foundry air IAD
MT-222 new airline LHR
MT-222 new airline CPH
MT-222 new airline JFK
MT-222 new airline IAD
PA-452 new air LHR
PA-452 new air CPH
PA-452 new air JFK
PA-452 new air IAD

Example 2: Base case

Argument values:

  • Condition for columns to select on the left:
    allColumns(

    )
  • Condition for columns to select on the right:
    columnNameIsIn(
     columnNames: [home_airport],
    )
  • Left dataset: ri.foundry.main.dataset.left
  • Right dataset: ri.foundry.main.dataset.right
  • Prefix for columns from right: null

Inputs:

ri.foundry.main.dataset.left

tail_number airline miles factor
XB-123 foundry air 124 2
MT-222 new airline 1123 5
PA-452 new air 212 2

ri.foundry.main.dataset.right

tail_number home_airport
XB-123 LHR
MT-222 CPH
KK-452 JFK
JR-201 IAD

Output:

tail_number airline miles factor home_airport
XB-123 foundry air 124 2 LHR
XB-123 foundry air 124 2 CPH
XB-123 foundry air 124 2 JFK
XB-123 foundry air 124 2 IAD
MT-222 new airline 1123 5 LHR
MT-222 new airline 1123 5 CPH
MT-222 new airline 1123 5 JFK
MT-222 new airline 1123 5 IAD
PA-452 new air 212 2 LHR
PA-452 new air 212 2 CPH
PA-452 new air 212 2 JFK
PA-452 new air 212 2 IAD


中文翻译


交叉连接(Cross join)

支持模式:批处理(Batch)、快速(Faster)

交叉连接将左侧和右侧数据集输入进行匹配,将两侧的所有行与另一侧的所有行进行配对。输出结果为两个数据集的笛卡尔积(cartesian product)。

转换类别:连接(Join)

声明参数

  • 左侧列选择条件(Condition for columns to select on the left): 左侧输入模式中的所有列都将被测试,以判断是否满足此条件。若满足,该列将被选中并输出。
    ColumnPredicate
  • 右侧列选择条件(Condition for columns to select on the right): 右侧输入模式中的所有列都将被测试,以判断是否满足此条件。若满足,该列将被选中并输出。
    ColumnPredicate
  • 左侧数据集(Left dataset): 用于连接的左侧数据集。
    Table
  • 右侧数据集(Right dataset): 用于连接的右侧数据集。
    Table
  • 可选 右侧列前缀(Prefix for columns from right): 为右侧所有列添加的前缀。
    Literal\

示例

示例 1:基础情况

参数值:

  • 左侧列选择条件:
    columnNameIsIn(
     columnNames: [tail_number, airline],
    )
  • 右侧列选择条件:
    columnNameIsIn(
     columnNames: [home_airport],
    )
  • 左侧数据集: ri.foundry.main.dataset.left
  • 右侧数据集: ri.foundry.main.dataset.right
  • 右侧列前缀: null

输入:

ri.foundry.main.dataset.left

tail_number airline miles factor
XB-123 foundry air 124 2
MT-222 new airline 1123 5
PA-452 new air 212 2

ri.foundry.main.dataset.right

tail_number home_airport
XB-123 LHR
MT-222 CPH
KK-452 JFK
JR-201 IAD

输出:

tail_number airline home_airport
XB-123 foundry air LHR
XB-123 foundry air CPH
XB-123 foundry air JFK
XB-123 foundry air IAD
MT-222 new airline LHR
MT-222 new airline CPH
MT-222 new airline JFK
MT-222 new airline IAD
PA-452 new air LHR
PA-452 new air CPH
PA-452 new air JFK
PA-452 new air IAD

示例 2:基础情况

参数值:

  • 左侧列选择条件:
    allColumns(

    )
  • 右侧列选择条件:
    columnNameIsIn(
     columnNames: [home_airport],
    )
  • 左侧数据集: ri.foundry.main.dataset.left
  • 右侧数据集: ri.foundry.main.dataset.right
  • 右侧列前缀: null

输入:

ri.foundry.main.dataset.left

tail_number airline miles factor
XB-123 foundry air 124 2
MT-222 new airline 1123 5
PA-452 new air 212 2

ri.foundry.main.dataset.right

tail_number home_airport
XB-123 LHR
MT-222 CPH
KK-452 JFK
JR-201 IAD

输出:

tail_number airline miles factor home_airport
XB-123 foundry air 124 2 LHR
XB-123 foundry air 124 2 CPH
XB-123 foundry air 124 2 JFK
XB-123 foundry air 124 2 IAD
MT-222 new airline 1123 5 LHR
MT-222 new airline 1123 5 CPH
MT-222 new airline 1123 5 JFK
MT-222 new airline 1123 5 IAD
PA-452 new air 212 2 LHR
PA-452 new air 212 2 CPH
PA-452 new air 212 2 JFK
PA-452 new air 212 2 IAD