Repository navigation
Fix CAST type in multi-stage EXPLAIN when asking servers - #19768
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #19768 +/- ##
============================================
- Coverage 68.40% 68.40% -0.01%
Complexity 1470 1470
============================================
Files 3521 3521
Lines 229091 229097 +6
Branches 36346 36347 +1
============================================
- Hits 156707 156703 -4
+ Misses 60104 60101 -3
- Partials 12280 12293 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Jackie-Jiang
left a comment
There was a problem hiding this comment.
Reviewed the CAST-fix commit 046f050, excluding dependency #19766. The target type and operand nullability are reconstructed correctly, and the round-trip test covers the reported regression. LGTM, with one minor assertion-import nit.
All 13 reported CI checks pass for this commit. I did not run tests locally.
| Assert.assertTrue(rexNode.getType().isNullable()); | ||
| Assert.assertEquals(RexExpressionUtils.fromRexNode(rexNode), castCall); |
There was a problem hiding this comment.
Nit: Please use static imports for assertTrue and assertEquals in the new test, following the test assertion convention.
9220de7 to
9311f5b
Compare
9311f5b to
81a9779
Compare
PR flow
PR modifies toRexCall to correctly build Calcite CAST from operand and target type. (5 nodes, 5 edges)
AI-generated · Green: added · Yellow: modified · Red: removed · Gray: existing
Diff evidence
This PR fixes the
CASTitem in the "Limits" section of #19766.The bug
With
explainAskingServers(orpinot.query.multistage.explain.include.segment.plan),PlanNodeToRelConverterconverts the plan nodes from the servers back to Calcite nodes.A plan node holds
CAST(x AS T)as aCASTcall with two operands:x, and aSTRINGliteral with the name ofT(seeRexExpressionUtils.handleCast()).toRexCall()gives both operands to the CalciteCASToperator. Calcite then uses the type of the second operand as the type of the cast.For example, take this query with the default planner rules:
EXPLAIN shows:
Before #19766, the nodes with this
CASTusually showed asUnknown, so this bug was hidden.The fix
In
toRexCall(), createCASTwithRexBuilder.makeCast()from the first operand. Use the type of the call as the target type, with the nullability of the operand. This is the inverse ofhandleCast(). EXPLAIN now shows:Only the EXPLAIN output changes. Query execution does not use this conversion.
Testing
RexExpressionUtilsTest.testCastRoundTripconverts aCASTcall to a Calcite node and back. It also checks that a nullable operand gives a nullable cast. Without this change, the test fails inhandleCast(), which expects one operand.pinot.query.multistage.explain.include.segment.plan=trueand the default planner rules. EXPLAIN showsDIVIDE(CAST($2):DOUBLE NOT NULL, $3)and noUnknownnodes.pinot-query-plannertests pass.spotless,checkstyleandlicenseare clean.