You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user/ppl/cmd/join.rst
+12-6Lines changed: 12 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,22 +19,24 @@ Version
19
19
20
20
Syntax-1
21
21
========
22
-
|[joinType] join [leftAlias] [rightAlias] on <joinCriteria> <right-dataset>
22
+
|[joinType] join [max=n] [leftAlias] [rightAlias] (on | where) <joinCriteria> <right-dataset>
23
23
24
-
* joinType: optional. The type of join to perform. The default is ``INNER`` if not specified. Other option is ``LEFT [OUTER]``, ``RIGHT [OUTER]``, ``FULL [OUTER]``, ``CROSS``, ``[LEFT] SEMI``, ``[LEFT] ANTI``.
24
+
* joinType: optional. The type of join to perform. The default is ``inner`` if not specified. Other option is ``left``, ``outer``(alias of ``left``), ``semi``, ``anti`` and performance sensitive types ``right``, ``full`` and ``cross``.
25
+
* max=n: optional. Controls how many subsearch results could be joined against to each row in main search. The default value is 0, means unlimited.
25
26
* leftAlias: optional. The subsearch alias to use with the left join side, to avoid ambiguous naming. Fixed pattern: ``left = <leftAlias>``
26
27
* rightAlias: optional. The subsearch alias to use with the right join side, to avoid ambiguous naming. Fixed pattern: ``right = <rightAlias>``
27
-
* joinCriteria: mandatory. It could be any comparison expression.
28
+
* joinCriteria: mandatory. It could be any comparison expression. Must follow with ``on`` (since 3.0.0) or ``where`` (since 3.3.0) keyword.
28
29
* right-dataset: mandatory. Right dataset could be either an ``index`` or a ``subsearch`` with/without alias.
* type=<joinType>: optional. The type of join to perform. The default is ``INNER`` if not specified. Other option is ``LEFT``, ``RIGHT``, ``FULL``, ``CROSS``, ``SEMI``, ``ANTI``.
36
+
* type=<joinType>: optional. The type of join to perform. The default is ``INNER`` if not specified. Other option is ``left``, ``outer``(alias of ``left``), ``semi``, ``anti`` and performance sensitive types ``right``, ``full`` and ``cross``.
36
37
* overwrite=<bool>: optional. Specifies whether duplicate-named fields from <right-dataset> (subsearch results) should replace corresponding fields in the main search results. The default value is ``true``.
37
-
* join-field-list: optional. The fields to use to build join criteria. The ``join-field-list`` must be present in both sides. If no <join-field-list> is present, all fields that are common to both sides are used.
38
+
* max=n: optional. Controls how many subsearch results could be joined against to each row in main search. The default value is 0, means unlimited.
39
+
* join-field-list: optional. The fields to use to build join criteria. The ``join-field-list`` must be present in both sides. If no <join-field-list> is present, all fields that are common to both sides are used. The comma is optional.
38
40
* right-dataset: mandatory. Right dataset could be either an ``index`` or a ``subsearch`` with/without alias.
39
41
40
42
Configuration
@@ -69,6 +71,7 @@ Usage
69
71
Join (syntax-1)::
70
72
71
73
source = table1 | inner join left = l right = r on l.a = r.a table2 | fields l.a, r.a, b, c
74
+
source = table1 | inner join left = l right = r where l.a = r.a table2 | fields l.a, r.a, b, c
72
75
source = table1 | left join left = l right = r on l.a = r.a table2 | fields l.a, r.a, b, c
73
76
source = table1 | right join left = l right = r on l.a = r.a table2 | fields l.a, r.a, b, c
74
77
source = table1 | full left = l right = r on l.a = r.a table2 | fields l.a, r.a, b, c
@@ -86,6 +89,7 @@ Join (syntax-2)::
86
89
87
90
source = table1 | join a table2 | fields a, b, c
88
91
source = table1 | join a, b table2 | fields a, b, c
92
+
source = table1 | join type=outer a b table2 | fields a, b, c
89
93
source = table1 | join type=left overwrite=false a, b [source=table2 | rename d as b] | fields a, b, c
90
94
91
95
Example 1: Two indices join
@@ -179,3 +183,5 @@ Assume table1 and table2 only contain field ``id``, following PPL queries and th
179
183
- table1.id, tt.id, tt.b, a
180
184
181
185
But for the syntax-2 (since 3.2.0), duplicate-named fields in output results are deduplicated, with field retention determined by the value of 'overwrite' option.
186
+
187
+
Join types ``inner``, ``left``, ``outer`` (alias of ``left``), ``semi`` and ``anti`` are supported by default. ``right``, ``full``, ``cross`` are performance sensitive join types which are disabled by default. Set config ``plugins.calcite.all_join_types.allowed = true`` to enable.
0 commit comments