fix: [bug] PPL query with mvindex() fails when plugins.calcite.pushdown.enabled=true (#5660) - #5689
Conversation
PR Reviewer Guide 🔍(Review updated until commit a114262)Here are some key observations to aid the review process:
|
065908a to
ee33606
Compare
|
Persistent review updated to latest commit ee33606 |
PR Code Suggestions ✨Latest suggestions up to a114262 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 3cca658
Suggestions up to commit ee33606
|
dai-chen
left a comment
There was a problem hiding this comment.
Any unit or integration test to cover?
| Pair<SqlOperator, List<RexNode>> normalized = RexNormalize.normalize(call.op, call.operands); | ||
| List<RexNode> standardizedOperands = visitList(normalized.right, helper, update); | ||
| return helper.rexBuilder.makeCall(call.getType(), normalized.left, standardizedOperands); | ||
| RexNode result = |
There was a problem hiding this comment.
+1 to Chen's comment - lets add more testing coverage on the change
ee33606 to
3cca658
Compare
|
Persistent review updated to latest commit 3cca658 |
…hdown.enabled=true` (opensearch-project#5660) * Add Tests Signed-off-by: Ajimelec Gonzalez <ajimelec@amazon.com>
3cca658 to
a114262
Compare
|
Persistent review updated to latest commit a114262 |
Description
Fix Calcite pushdown
CompileExceptionwhere arithmetic in array index expressions (e.g.,mvindex(entity, 1)) produceslonginstead ofintat runtime.RexStandardizerwidens arithmetic operands toBIGINTfor doc-value compatibility, butPLUSnodes do not have their type serialized inJSON(unlikeCAST/MINUS). On deserialization the type is re-derived fromBIGINToperands, breaking operators likeITEMthat expectint.Fix: Wrap arithmetic results in an explicit
CAST(INTEGER)inRexStandardizer.visitCall()when the original type is narrower thanBIGINT.CASTnodes always serialize their type, soINTEGERis preserved through serialization and deserialization.Test Added:
testArithmeticInItemIndexPreservesIntegerType:PLUS(int, int)preservesINTEGERtype through serialization round-trip (the main bug fix)testArithmeticBigintNotWrappedInCast:PLUS(bigint, bigint)staysBIGINTwithout unnecessaryCAST(no regression)testArithmeticWithFieldPreservesIntegerType:field_ref + 1where field isINTEGERpreservesINTEGER(field-based index scenario)Related Issues
Resolves #5660
See also: #5670 (alternative plan-layer fix that is ineffective because the serialization layer overrides it)
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.