Skip to content

Commit 7fcf1b3

Browse files
alex-spiesywangd
authored andcommitted
ESQL: Document LU JOIN/MV_EXPAND not respecting SORT (elastic#127718)
1 parent fd56174 commit 7fcf1b3

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

docs/reference/query-languages/esql/_snippets/commands/layout/lookup-join.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ If multiple documents in the lookup index match a single row in your
4242
results, the output will contain one row for each matching combination.
4343

4444
::::{tip}
45-
In case of name collisions, the newly created columns will override existing columns.
45+
For important information about using `LOOKUP JOIN`, refer to [Usage notes](../../../../esql/esql-lookup-join.md#usage-notes).
4646
::::
4747

4848
**Examples**

docs/reference/query-languages/esql/_snippets/commands/layout/mv_expand.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ MV_EXPAND column
2222
`column`
2323
: The multivalued column to expand.
2424

25+
::::{warning}
26+
The output rows produced by `MV_EXPAND` can be in any order and may not respect
27+
preceding `SORT`s. To guarantee a certain ordering, place a `SORT` after any
28+
`MV_EXPAND`s.
29+
::::
30+
2531
**Example**
2632

2733
:::{include} ../examples/mv_expand.csv-spec/simple.md

docs/reference/query-languages/esql/esql-lookup-join.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,27 @@ To obtain a join key with a compatible type, use a [conversion function](/refere
156156

157157
For a complete list of supported data types and their internal representations, see the [Supported Field Types documentation](/reference/query-languages/esql/limitations.md#_supported_types).
158158

159+
## Usage notes
160+
161+
This section covers important details about `LOOKUP JOIN` that impact query behavior and results. Review these details to ensure your queries work as expected and to troubleshoot unexpected results.
162+
163+
### Handling name collisions
164+
165+
When fields from the lookup index match existing column names, the new columns override the existing ones.
166+
Before the `LOOKUP JOIN` command, preserve columns by either:
167+
168+
* Using `RENAME` to assign non-conflicting names
169+
* Using `EVAL` to create new columns with different names
170+
171+
### Sorting behavior
172+
173+
The output rows produced by `LOOKUP JOIN` can be in any order and may not
174+
respect preceding `SORT`s. To guarantee a certain ordering, place a `SORT` after
175+
any `LOOKUP JOIN`s.
176+
159177
## Limitations
160178

161-
The following are the current limitations with `LOOKUP JOIN`
179+
The following are the current limitations with `LOOKUP JOIN`:
162180

163181
* Indices in [`lookup` mode](/reference/elasticsearch/index-settings/index-modules.md#index-mode-setting) are always single-sharded.
164182
* Cross cluster search is unsupported initially. Both source and lookup indices must be local.

0 commit comments

Comments
 (0)