[BugFix] Accept single values in mvindex and date/time values in split (#5948) #5955
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.45) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 418 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.361
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #5955"
general
weight: 0.35
Swiddis
Description
mvindexrejected a plain (single-value) field withMVINDEX function expects {[ARRAY,INTEGER]|[ARRAY,INTEGER,INTEGER]}, but got [STRING,INTEGER], andsplitrejected date/time values withSPLIT function expects {[STRING,STRING]}, but got [TIMESTAMP,STRING]. SPL treats single-value and multi-value fields interchangeably, so these queries fail when migrated.This follows the fix proposed in the issue:
mvindexnow also accepts a non-array first argument and treats it as a one-element array (MVIndexFunctionImp, plus a secondANYsignature inPPLFuncImpTable; array arguments keep the existing path).-
mvindex(value, 0)andmvindex(value, -1)return the value; any other index returnsnull. The value keeps its own type (string, number, timestamp, ...).-
mvindex(value, start, end)wraps the value witharray(value)and slices it as before, so a covering range returns a one-element array.- A null value returns
null, not a one-element array holding null, soisnull(mvindex(field, 0))keeps working.splitnow also acceptsDATE,TIMEandTIMESTAMPinput. The value is cast to its string form the same waycast(value as string)is, sosplit(ts, "-")returns the same result assplit(cast(ts as string), "-"). Other non-string types (for example numbers) are still rejected.The issue mentions the other
mvfunctions may want the same treatment; I kept this PR to the two functions in the report and can follow up on the others if wanted.Docs for
mvindexandsplitindocs/user/ppl/functions/collection.mdare updated.Related Issues
Resolves #5948
Check List
- Unit tests in
CalcitePPLArrayFunctionTest(string, number, null and computed-index single values, ranges,spliton a date and the explicit-cast equivalent, and the existing type errors for non-integer indexes and numericsplitinput). 7 of them fail without the fix.- Integration tests in
CalciteArrayFunctionIT(also run throughCalciteNoPushdownIT).- YAML REST test
issues/5948.ymlusing the reproduction from the issue.- [x] New functionality has javadoc added.
- [x] New functionality has a user manual doc added.
--signoffor-s.Tested locally with
./gradlew spotlessCheck :core:test :ppl:test :opensearch:test :sql:test,./gradlew :integ-test:integTest -Dtests.class="CalciteArrayFunctionIT"and./gradlew :integ-test:yamlRestTest -Dtests.method="test {yaml=issues/5948/*}".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.