-
Notifications
You must be signed in to change notification settings - Fork 181
Feature/mvcombine #5025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/mvcombine #5025
Conversation
Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com>
Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com>
Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com>
Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com>
Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com>
Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com>
yuancu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing! I left a few comments.
integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteMvCombineCommandIT.java
Outdated
Show resolved
Hide resolved
integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteMvCombineCommandIT.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/calcite/CalciteRelNodeVisitor.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/calcite/CalciteRelNodeVisitor.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/calcite/CalciteRelNodeVisitor.java
Show resolved
Hide resolved
Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com>
|
Addressed the comments and tested locally to verify the results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
🤖 Fix all issues with AI agents
In `@core/src/main/java/org/opensearch/sql/calcite/CalciteRelNodeVisitor.java`:
- Around line 3353-3360: The metadata NULL projection is using the
post-aggregate schema from relBuilder.peek() which misindexes fields; in
CalciteRelNodeVisitor, capture and store the original input field types at the
start of visitMvCombine (e.g., a List of RelDataType or Type information from
the input row type) and pass that into restoreColumnOrderAfterArrayAgg; then
modify restoreColumnOrderAfterArrayAgg so when isMetadataField(fieldName) is
true it looks up the type from the saved original input types (instead of
relBuilder.peek().getRowType().getFieldList().get(i).getType()) and uses that
type for makeNullLiteral, ensuring projections are built from the original
schema.
In `@docs/user/ppl/cmd/mvcombine.md`:
- Line 60: Update the documentation descriptions so the dataset name matches the
queries by replacing references to "mvcombine" with "mvcombine_data" in the text
surrounding the examples (the occurrences around the lines that currently say
"Given a dataset mvcombine"), ensuring both places (the one at line ~60 and the
one at line ~92) use "mvcombine_data" to match the query source names.
- Line 117: Rename the heading text "Example 5: Error when field does not exist"
to "Example 4: Error when field does not exist" so example numbering is
sequential; locate the heading string in the mvcombine docs (the line containing
"Example 5: Error when field does not exist") and update it, then scan
subsequent example headings to ensure no other numbering gaps or off-by-one
issues.
- Line 58: The "Example 2" line is missing the Markdown header prefix and the
example numbering jumps (Example 3 -> Example 5); update the "Example 2" line to
include the same header style used for other examples (add "## " before "Example
2") and renumber the subsequent examples to maintain a sequential order (adjust
"Example 5" to "Example 4" or otherwise fix numbering so Example 1, Example 2,
Example 3, Example 4, etc.), referencing the visible example headings "Example
1", "Example 2", "Example 3", and "Example 5" to locate the spots to change.
In
`@integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteMvCombineCommandIT.java`:
- Around line 195-203: Add missing null/boundary/invalid-input tests for the
mvcombine command: extend CalciteMvCombineCommandIT by adding new test methods
alongside testMvCombine_missingField_shouldReturn4xx that call executeQuery with
cases for null/empty input (e.g., "mvcombine " with no field or explicit null
values), boundary/empty collections, non-direct field references (e.g., function
or expression instead of field name) and already-multivalue fields; assert
proper 4xx/validation responses or expected behavior via ResponseException
status checks and positive assertions where applicable; use the existing pattern
in testMvCombine_missingField_shouldReturn4xx and reference executeQuery and
mvcombine to locate where to add tests.
- Around line 122-149: The current test
testMvCombine_multipleGroups_producesOneRowPerGroupKey uses loose OR checks on
mv0/mv1 which can hide grouping regressions; tighten it by asserting the sorted
row IPs explicitly (inspect result -> datarows -> each row's ip column) to
ensure row 0 is "10.0.0.7" and row 1 is "10.0.0.8", then validate the mv
contents per group deterministically (check mv0 contains the expected set for
10.0.0.7 and mv1 contains the expected set for 10.0.0.8) instead of the current
OR-based assertions—update references in this test to use the ip values from
r0.get(0)/r1.get(0) and assert exact membership of mv0/mv1 accordingly.
core/src/main/java/org/opensearch/sql/calcite/CalciteRelNodeVisitor.java
Outdated
Show resolved
Hide resolved
integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteMvCombineCommandIT.java
Outdated
Show resolved
Hide resolved
integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteMvCombineCommandIT.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com>
Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com>
Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com>
Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com>
core/src/main/java/org/opensearch/sql/calcite/CalciteRelNodeVisitor.java
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/ast/analysis/FieldResolutionVisitor.java
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/ast/analysis/FieldResolutionVisitor.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com>
Signed-off-by: Srikanth Padakanti <srikanth29.9@gmail.com>
Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com>
|
@ykmr1224 @anasalkouz |
yuancu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the change!
|
The backport to To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/sql/backport-2.19-dev 2.19-dev
# Navigate to the new working tree
pushd ../.worktrees/sql/backport-2.19-dev
# Create a new branch
git switch --create backport/backport-5025-to-2.19-dev
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 92e73ead7c05c97668510de5cae246bdfdcff394
# Push it to GitHub
git push --set-upstream origin backport/backport-5025-to-2.19-dev
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/sql/backport-2.19-devThen, create a pull request where the |
|
Thanks for your contribution, merged to main |
* MvCombine Command Feature Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * MvCombine Command Feature Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Add doctests to MvCombine Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * spotlesscheck apply Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * spotlesscheck apply Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * spotlesscheck apply Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * spotlessapply Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address coderrabbit comments Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address coderrabbit comments Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address coderrabbit comments Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address coderrabbit comments Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address coderrabbit comments Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address coderrabbit comments Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Add mvcombine to index.md Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Remove the nomv related implementation as that command is still not yet implemented Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Remove the nomv related implementation as that command is still not yet implemented Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Remove the nomv related implementation as that command is still not yet implemented Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Remove the nomv related implementation as that command is still not yet implemented Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * complete the checklist from ppl-commands.md Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * spotlessApply Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Add visitMvCombine method to the FieldResolutionVisitor Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Apply spotlesscheck Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Add changes to exclude the metadata fields and remove the CAST logic Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address CrossClusterSearchIT comment Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address CrossClusterSearchIT comment Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address CrossClusterSearchIT comment Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Coderrabbit issues Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Coderrabbit issues Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Coderrabbit issues Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Coderrabbit issues Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address comments Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address comments Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> --------- Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> Signed-off-by: Srikanth Padakanti <srikanth29.9@gmail.com> Co-authored-by: Srikanth Padakanti <srikanth_padakanti@apple.com> # Conflicts: # integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteExplainIT.java # ppl/src/main/antlr/OpenSearchPPLParser.g4
* MvCombine Command Feature Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * MvCombine Command Feature Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Add doctests to MvCombine Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * spotlesscheck apply Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * spotlesscheck apply Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * spotlesscheck apply Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * spotlessapply Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address coderrabbit comments Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address coderrabbit comments Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address coderrabbit comments Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address coderrabbit comments Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address coderrabbit comments Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address coderrabbit comments Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Add mvcombine to index.md Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Remove the nomv related implementation as that command is still not yet implemented Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Remove the nomv related implementation as that command is still not yet implemented Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Remove the nomv related implementation as that command is still not yet implemented Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Remove the nomv related implementation as that command is still not yet implemented Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * complete the checklist from ppl-commands.md Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * spotlessApply Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Add visitMvCombine method to the FieldResolutionVisitor Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Apply spotlesscheck Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Add changes to exclude the metadata fields and remove the CAST logic Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address CrossClusterSearchIT comment Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address CrossClusterSearchIT comment Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address CrossClusterSearchIT comment Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Coderrabbit issues Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Coderrabbit issues Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Coderrabbit issues Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Coderrabbit issues Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address comments Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> * Address comments Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> --------- Signed-off-by: Srikanth Padakanti <srikanth_padakanti@apple.com> Signed-off-by: Srikanth Padakanti <srikanth29.9@gmail.com> Co-authored-by: Srikanth Padakanti <srikanth_padakanti@apple.com> # Conflicts: # integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteExplainIT.java # ppl/src/main/antlr/OpenSearchPPLParser.g4
Description
This change introduces the mvcombine PPL command, which combines values of a specified field across rows that are identical on all other fields in the current result set.
mvcombine behaves as a pipeline-level grouping operator: it collapses matching rows into a single row and aggregates the target field values into a multivalue field, while preserving all non-target fields.
Command
mvcombine [delim=""]
Arguments
field (required)
The field whose values will be combined.
delim (optional)
Delimiter to be used when rendering a single-value representation of the combined field.
Semantics
mvcombine operates on the current result set.
Rows are grouped where all fields except have identical values.
For each group:
Scope clarification
Related Issues
Resolves #4766
#4766
Check List
--signoffor-s.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.