Fix QTF stitcher precision mismatch on date_nanos fields#22095
Conversation
a79bbf3 to
b381103
Compare
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
3989c62 to
db76edf
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #22095 +/- ##
============================================
- Coverage 73.52% 73.48% -0.05%
+ Complexity 75682 75673 -9
============================================
Files 6038 6038
Lines 343009 343011 +2
Branches 49348 49348
============================================
- Hits 252189 252045 -144
- Misses 70746 70973 +227
+ Partials 20074 19993 -81 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
db76edf to
ac69c17
Compare
ArrowCalciteTypes.toArrow() hardcoded TimeUnit.MILLISECOND for every Calcite TIMESTAMP, so the late-materialization Stitcher pre-allocated a TimestampMilliVector for the output VSR. Shards correctly emitted Timestamp(NANOSECOND) for date_nanos fields, and Arrow's BaseFixedWidthVector.copyFromSafe requires identical fixed-width subclasses, so it tripped on every shard's response with a message-less IllegalArgumentException — surfacing to clients as HTTP 400 "Invalid Query". Plan shape required to fire: multi-shard parquet-backed index with date_nanos + Timestamp in projection + sort + head N (or other top-K) + at least one fetch-only field above the anchor. Drop any one and the rewriter declines QTF or the bug doesn't fire. Fix: branch on Calcite precision. precision == 9 -> NANOSECOND, else MILLISECOND. BackendPlanAdapter preserves precision through CAST rewrites, so the value is reliable (verified via DEBUG plan dump showing TIMESTAMP(9) survives). - Unit: ArrowCalciteTypesTests adds 3 cases covering precision 3, 9, default. The factory uses an extended RelDataTypeSystemImpl that lifts MAX_DATETIME precision to 9 — default Calcite caps at 3 and would silently clamp the test input. - IT: LateMaterializationDateNanosIT spins a 2-shard parquet+lucene index with date_nanos and runs the q01-style plan (match + sort - ts + head + fetch-only field). Pre-fix: HTTP 400 with the exact bug signature. Post-fix: 4 rows in DESC order with sub-millisecond precision preserved. Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
…SHOT Aligns the local sandbox with the OpenSearch core 3.8 bump (opensearch-project#22090). The SQL plugin and job-scheduler plugin use a four-segment version scheme (major.minor.patch.0-SNAPSHOT) tracking core's three-segment 3.8.0. - sandbox/qa/analytics-engine-rest/build.gradle: jobSchedulerPlugin and sqlPlugin zip dependencies pulled from OpenSearch Snapshots. - sandbox/plugins/test-ppl-frontend/build.gradle: default fallback for -PsqlUnifiedQueryVersion (override-able for local sql-repo builds). Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
c71786a to
5de9bbc
Compare
…project#22095) * Honour Calcite TIMESTAMP precision in QTF stitcher output schema ArrowCalciteTypes.toArrow() hardcoded TimeUnit.MILLISECOND for every Calcite TIMESTAMP, so the late-materialization Stitcher pre-allocated a TimestampMilliVector for the output VSR. Shards correctly emitted Timestamp(NANOSECOND) for date_nanos fields, and Arrow's BaseFixedWidthVector.copyFromSafe requires identical fixed-width subclasses, so it tripped on every shard's response with a message-less IllegalArgumentException — surfacing to clients as HTTP 400 "Invalid Query". Plan shape required to fire: multi-shard parquet-backed index with date_nanos + Timestamp in projection + sort + head N (or other top-K) + at least one fetch-only field above the anchor. Drop any one and the rewriter declines QTF or the bug doesn't fire. Fix: branch on Calcite precision. precision == 9 -> NANOSECOND, else MILLISECOND. BackendPlanAdapter preserves precision through CAST rewrites, so the value is reliable (verified via DEBUG plan dump showing TIMESTAMP(9) survives). - Unit: ArrowCalciteTypesTests adds 3 cases covering precision 3, 9, default. The factory uses an extended RelDataTypeSystemImpl that lifts MAX_DATETIME precision to 9 — default Calcite caps at 3 and would silently clamp the test input. - IT: LateMaterializationDateNanosIT spins a 2-shard parquet+lucene index with date_nanos and runs the q01-style plan (match + sort - ts + head + fetch-only field). Pre-fix: HTTP 400 with the exact bug signature. Post-fix: 4 rows in DESC order with sub-millisecond precision preserved. Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com> * chore: bump opensearch-sql / opensearch-job-scheduler to 3.8.0.0-SNAPSHOT Aligns the local sandbox with the OpenSearch core 3.8 bump (opensearch-project#22090). The SQL plugin and job-scheduler plugin use a four-segment version scheme (major.minor.patch.0-SNAPSHOT) tracking core's three-segment 3.8.0. - sandbox/qa/analytics-engine-rest/build.gradle: jobSchedulerPlugin and sqlPlugin zip dependencies pulled from OpenSearch Snapshots. - sandbox/plugins/test-ppl-frontend/build.gradle: default fallback for -PsqlUnifiedQueryVersion (override-able for local sql-repo builds). Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com> --------- Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
Description
ArrowCalciteTypes.toArrow()hardcodedTimeUnit.MILLISECONDfor every CalciteTIMESTAMP. Shards emitTimestamp(NANOSECOND)fordate_nanos, but the late-materialization Stitcher pre-allocated aTimestampMilliVectorfor the output. Arrow'scopyFromSaferequires identical fixed-width subclasses, so it threw an emptyIllegalArgumentException— surfacing to clients as HTTP 400 "Invalid Query".Fix: branch on Calcite precision —
precision == 9 → NANOSECOND, elseMILLISECOND.Query shapes this fixes
Triggered on a multi-shard parquet-backed index with a
date_nanosfield when the plan includes:date_nanoscolumnhead N(or other top-K)Example PPL:
Drop any of those and the LM rewriter declines QTF or the bug doesn't fire.
Tests
ArrowCalciteTypesTests— 3 new cases covering precision 3, 9, and default.LateMaterializationDateNanosIT— new 2-shard parquet+lucene IT running the q01-style plan. Pre-fix: HTTP 400. Post-fix: 4 rows in DESC order with sub-millisecond precision preserved.Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.