{{ message }}
Add validation for expand command on scalar types (#5065)#5089
Closed
penghuo wants to merge 6 commits into
Closed
Conversation
Signed-off-by: Peng Huo <penghuo@gmail.com>
…/index keywords When a PPL query contains duplicate 'source' or 'index' keywords (e.g., 'source source=index_name'), the parser was accepting it as valid syntax, treating the first keyword as a search expression. This caused confusing errors later when OpenSearch tried to expand fields. This fix adds validation in AstBuilder.visitSearchFrom() to detect when reserved keywords 'source' or 'index' appear as search expressions before the fromClause. It now throws a clear SyntaxCheckException with a helpful error message suggesting the correct syntax. Signed-off-by: Peng Huo <penghuo@gmail.com>
Signed-off-by: Peng Huo <penghuo@gmail.com>
…e source/index keywords" This reverts commit 268f77b.
Signed-off-by: Peng Huo <penghuo@gmail.com>
…#5065) - Validate field type in buildExpandRelNode before uncollect operation - Throw UnsupportedOperationException with clear message for scalar types - OpenSearch multi-value fields stored as scalars cannot be expanded when codegen triggered - Add integration test to verify error message Signed-off-by: Peng Huo <penghuo@gmail.com>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Add validation to reject
expandcommand on scalar types with a clear error message. This addresses issue #5065 where expand fails with a confusing "UNNEST argument must be a collection" error when used on OpenSearch multi-value fields.Root Cause:
OpenSearch doesn't have an ARRAY type. Multi-value fields like
[1, 2, 3]are stored as repeated scalar values (e.g., typelong). When Calcite'suncollectoperation is triggered during codegen, it expectsArraySqlTypebut receivesBasicSqlType(BIGINT), causing a CalciteException.Solution:
Validate the field type at planning time and fail fast with a descriptive error message explaining that expand only works on explicitly defined array types, not OpenSearch's implicit multi-value fields.
Impact:
expandcommandRelated Issues
Resolves #5065
Testing
Issue5065ITthat verifies the error messageCalciteExpandCommandIT)./gradlew :integ-test:integTest --tests "org.opensearch.sql.calcite.Issue5065IT"Check List