You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "yashmayya (via GitHub)" <gi...@apache.org> on 2026/10/06 18:07:17 UTC
[PR] Fix CAST type in multi-stage EXPLAIN when asking servers [pinot]
yashmayya opened a new pull request, #19768:
URL: https://github.com/apache/pinot/pull/19768
Depends on #19766. This branch includes the commit of #19766, so review only the last commit.
This PR fixes the `CAST` item in the "Limits" section of #19766.
## The bug
With `explainAskingServers` (or `pinot.query.multistage.explain.include.segment.plan`), `PlanNodeToRelConverter` converts the plan nodes from the servers back to Calcite nodes.
A plan node holds `CAST(x AS T)` as a `CAST` call with two operands: `x`, and a `STRING` literal with the name of `T` (see `RexExpressionUtils.handleCast()`). `toRexCall()` gives both operands to the Calcite `CAST` operator. 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:
```sql
SELECT Carrier, SUM(v) FROM (SELECT /*+ aggOptions(is_partitioned_by_group_by_keys='true') */ Carrier, Origin, AVG(ArrDelay) AS v FROM mytable GROUP BY Carrier, Origin) GROUP BY Carrier
```
EXPLAIN shows:
```
LogicalProject(Carrier=[$0], $f1=[DIVIDE(CAST($2, 'DOUBLE'):CHAR(6) NOT NULL, $3)])
```
Before #19766, the nodes with this `CAST` usually showed as `Unknown`, so this bug was hidden.
## The fix
In `toRexCall()`, create `CAST` with `RexBuilder.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 of `handleCast()`. EXPLAIN now shows:
```
LogicalProject(Carrier=[$0], $f1=[DIVIDE(CAST($2):DOUBLE NOT NULL, $3)])
```
Only the EXPLAIN output changes. Query execution does not use this conversion.
## Testing
- `RexExpressionUtilsTest.testCastRoundTrip` converts a `CAST` call to a Calcite node and back. It also checks that a nullable operand gives a nullable cast. Without this change, the test fails in `handleCast()`, which expects one operand.
- I ran the query above in a temporary integration test with `pinot.query.multistage.explain.include.segment.plan=true` and the default planner rules. EXPLAIN shows `DIVIDE(CAST($2):DOUBLE NOT NULL, $3)` and no `Unknown` nodes.
- All 2659 `pinot-query-planner` tests pass. `spotless`, `checkstyle` and `license` are clean.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Fix CAST type in multi-stage EXPLAIN when asking servers [pinot]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #19768:
URL: https://github.com/apache/pinot/pull/19768#issuecomment-6023152553
## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/19768?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 100.00%. Comparing base ([`c9af1d0`](https://app.codecov.io/gh/apache/pinot/commit/c9af1d06ae20c538fb5646c0733133fcdda00a1b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`046f050`](https://app.codecov.io/gh/apache/pinot/commit/046f0502240e15a6a96874d539ba89ddea4d0ece?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 1 commits behind head on master.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #19768 +/- ##
==============================================
+ Coverage 58.16% 100.00% +41.83%
+ Complexity 7 6 -1
==============================================
Files 2712 3 -2709
Lines 167522 6 -167516
Branches 27368 0 -27368
==============================================
- Hits 97436 6 -97430
+ Misses 61903 0 -61903
+ Partials 8183 0 -8183
```
| [Flag](https://app.codecov.io/gh/apache/pinot/pull/19768/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [integration](https://app.codecov.io/gh/apache/pinot/pull/19768/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ø> (ø)` | |
| [integration1](https://app.codecov.io/gh/apache/pinot/pull/19768/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ø> (ø)` | |
| [integration2](https://app.codecov.io/gh/apache/pinot/pull/19768/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [java-25](https://app.codecov.io/gh/apache/pinot/pull/19768/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ø> (+41.83%)` | :arrow_up: |
| [lane-a](https://app.codecov.io/gh/apache/pinot/pull/19768/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ø> (ø)` | |
| [lane-b](https://app.codecov.io/gh/apache/pinot/pull/19768/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `0.00% <ø> (ø)` | |
| [temurin](https://app.codecov.io/gh/apache/pinot/pull/19768/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ø> (+41.83%)` | :arrow_up: |
| [unittests](https://app.codecov.io/gh/apache/pinot/pull/19768/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unittests1](https://app.codecov.io/gh/apache/pinot/pull/19768/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/pinot/pull/19768?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Fix CAST type in multi-stage EXPLAIN when asking servers [pinot]
Posted by "yashmayya (via GitHub)" <gi...@apache.org>.
yashmayya merged PR #19768:
URL: https://github.com/apache/pinot/pull/19768
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Fix CAST type in multi-stage EXPLAIN when asking servers [pinot]
Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang commented on code in PR #19768:
URL: https://github.com/apache/pinot/pull/19768#discussion_r4201429114
##########
pinot-query-planner/src/test/java/org/apache/pinot/query/planner/logical/RexExpressionUtilsTest.java:
##########
@@ -71,6 +72,36 @@ public void testUuidLiteralRoundTrip() {
Assert.assertEquals(roundTrip.getValue(), uuid);
}
+ @Test
+ public void testSqlKindFunctionNames() {
+ // Plan nodes name most standard operators by SqlKind, e.g. DIVIDE for "/" and SUM0 for "$SUM0"
+ RelBuilder relBuilder = RelBuilder.create(Frameworks.newConfigBuilder().build()).values(new String[]{"a"}, 1.0);
+ RexExpression input = new RexExpression.InputRef(0);
+ List<RexExpression> inOperands = List.of(input, new RexExpression.Literal(ColumnDataType.DOUBLE, 1.0),
+ new RexExpression.Literal(ColumnDataType.DOUBLE, 2.0));
+ for (RexExpression call : List.of(
+ new RexExpression.FunctionCall(ColumnDataType.DOUBLE, SqlKind.DIVIDE.name(), List.of(input, input)),
+ new RexExpression.FunctionCall(ColumnDataType.BOOLEAN, SqlKind.IN.name(), inOperands),
+ new RexExpression.FunctionCall(ColumnDataType.BOOLEAN, SqlKind.NOT_IN.name(), inOperands))) {
+ Assert.assertEquals(RexExpressionUtils.fromRexNode(RexExpressionUtils.toRexNode(relBuilder, call)), call);
+ }
+ RexExpression.FunctionCall sum0 =
+ new RexExpression.FunctionCall(ColumnDataType.DOUBLE, SqlKind.SUM0.name(), List.of(input));
+ Assert.assertSame(RexExpressionUtils.getAggFunction(sum0), SqlStdOperatorTable.SUM0);
+ }
+
+ @Test
+ public void testCastRoundTrip() {
+ // Plan nodes hold the target type of CAST as a STRING literal operand. Field "a" is a nullable INTEGER.
+ RelBuilder relBuilder =
+ RelBuilder.create(Frameworks.newConfigBuilder().build()).values(new String[]{"a"}, 1, null);
+ RexExpression castCall = new RexExpression.FunctionCall(ColumnDataType.DOUBLE, SqlKind.CAST.name(),
+ List.of(new RexExpression.InputRef(0), new RexExpression.Literal(ColumnDataType.STRING, "DOUBLE")));
+ RexNode rexNode = RexExpressionUtils.toRexNode(relBuilder, castCall);
+ Assert.assertTrue(rexNode.getType().isNullable());
+ Assert.assertEquals(RexExpressionUtils.fromRexNode(rexNode), castCall);
Review Comment:
Nit: Please use static imports for `assertTrue` and `assertEquals` in the new test, following the test assertion convention.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org