Repository navigation
Support expand command with Calcite - #3745
Conversation
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
|
TODOs:
|
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
| ============ | ||
| (From 3.1.0) | ||
|
|
||
| Use the ``expand`` command on a nested array field to transform a single |
There was a problem hiding this comment.
nested array -> array? why emphasized nested?
There was a problem hiding this comment.
This is because the boundary between array and object is blurry in OpenSearch. For example, a string field can store a string or an array of string. But there isn't an array type of string. Array only exists for nested type, where it stores an array of structs.
The current implementation does not support expanding an array of string stored in a string field since it will only read the string field as string, it doesn't know whether it is an array of string or a single string at the time of generating logical plans. That's why I specifically mentioned nested array.
|
|
||
| expand <field> [as alias] | ||
|
|
||
| * field: The field to be expanded (exploded). Currently only nested arrays are |
There was a problem hiding this comment.
Currently only nested arrays are supported?
It is not limitation of Expand command. Expand command does not aware of OpenSearch nested data type, right?
Is it because PPL engine map OpenSerach nested data type to PPL Array data type?
There was a problem hiding this comment.
Yes, expand command does not array of the nested type. This limitation originates from the fact that only nested fields are read as arrays in visitExpand in CalciteRelNodeVisitor. Primitive fields storing arrays are read as primitive types.
| schema("age", "bigint"), | ||
| schema("id", "bigint"), | ||
| schema("address", "struct")); | ||
| verifyDataRows( |
There was a problem hiding this comment.
nit: test should be specific, only focus on empty array.
| // The element type of struct and array is currently set to ANY. | ||
| // We set them using the runtime type as a workaround. |
There was a problem hiding this comment.
The element type of struct and array is currently set to ANY.
It is short-term solution, right? if so, add TODO, and issue link?
There was a problem hiding this comment.
Yes. Added. Thanks for pointing this out.
| // be used by the right side to correlate with the left side. | ||
| // Using left join to keep the records where the array field is empty. The corresponding | ||
| // field in the result will be null. | ||
| relBuilder.correlate(JoinRelType.LEFT, correlVariable.get().id, List.of(arrayFieldRex)); |
There was a problem hiding this comment.
Create an issue to track enforce limitation on Expand command.
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
…orkaround Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
|
Just to confirm: when the field to expand is an empty array, should I keep it in the result? @LantaoJin @qianheng-aws @penghuo The current implementation keeps it, with the corresponding expanded value set to E.g. for expanding employees results in
|
Signed-off-by: Yuanchun Shen <[email protected]>
* Create scalffolds for implementing expand command Signed-off-by: Yuanchun Shen <[email protected]> * WIP: Implementing expand command Signed-off-by: Yuanchun Shen <[email protected]> * Add array json and index mapping Signed-off-by: Yuanchun Shen <[email protected]> * WIP: Implementing expand command Signed-off-by: Yuanchun Shen <[email protected]> * Implement a minimal viable version of expand Signed-off-by: Yuanchun Shen <[email protected]> * Support expand with alias Signed-off-by: Yuanchun Shen <[email protected]> * Add doc for expand Signed-off-by: Yuanchun Shen <[email protected]> * WIP: add unit tests for expand command Signed-off-by: Yuanchun Shen <[email protected]> * Remove unused logical expand & add test cases Signed-off-by: Yuanchun Shen <[email protected]> * Use left join in expand to keep documents where their expanded array field is empty Signed-off-by: Yuanchun Shen <[email protected]> * Add unit test for expand command Signed-off-by: Yuanchun Shen <[email protected]> * Update expand doc format Signed-off-by: Yuanchun Shen <[email protected]> * Fix: delete test doc with refresh Signed-off-by: Yuanchun Shen <[email protected]> * Improve expand documentation Signed-off-by: Yuanchun Shen <[email protected]> * Fix typos Signed-off-by: Yuanchun Shen <[email protected]> * Add a version section to expand documentation Signed-off-by: Yuanchun Shen <[email protected]> * Make expand empty array IT more specific Signed-off-by: Yuanchun Shen <[email protected]> * Add a limitation section in expand doc & link a issue tracker for a workaround Signed-off-by: Yuanchun Shen <[email protected]> * Tweak expand command doc Signed-off-by: Yuanchun Shen <[email protected]> * Test expand null field Signed-off-by: Yuanchun Shen <[email protected]> --------- Signed-off-by: Yuanchun Shen <[email protected]> Signed-off-by: xinyual <[email protected]>
Description
Support
expandcommand with Calcite.Note:
expandonly explodes nested arrays, not maps.Related Issues
Resolves #3711
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.