You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "rsrkpatwari1234 (via GitHub)" <gi...@apache.org> on 2026/04/09 11:34:31 UTC
[I] Fix CastTypeAliasRewriter to recurse into nested CAST operands for SSE [pinot]
rsrkpatwari1234 opened a new issue, #18152:
URL: https://github.com/apache/pinot/issues/18152
### Summary
The rewriter from #16682 only rewrites the type literal on each CAST node and does not recurse into the first operand (the expression being cast). So CAST nodes nested inside the first operand of another CAST (or under that subtree, e.g. inside divide) can still leave BIGINT (and similarly VARBINARY, etc.) in the plan. Mixed-version clusters (new broker (with 1.4), pre-#16682-server semantics on 1.3 servers) then hit:
> IllegalArgumentException: Unable to cast expression to type - BIGINT
During rolling upgrades, queries that nest CAST(... AS LONG) (→ BIGINT in the plan) under another CAST or under an expression that is the first operand of an outer CAST can fail on older servers because CastTypeAliasRewriter never visited those inner CASTs before dispatch.
### Sample queries / patterns that can fail
1. Minimal nested cast (inner LONG, outer non-rewritten type like DOUBLE):
```
SELECT CAST(CAST(event_timestamp AS LONG) AS DOUBLE)
FROM my_table
LIMIT 1;
```
2. Same shape in GROUP BY :
```
SELECT COUNT(*)
FROM my_table
GROUP BY
dateTrunc(
'DAY',
CAST((CAST(event_timestamp AS LONG) / 1000) AS DOUBLE),
'SECONDS',
'UTC',
'MILLISECONDS'
)
```
3. Explicit double cast:
```
SELECT CAST(CAST(metric_col AS LONG) AS INT)
FROM my_table
LIMIT 10;
```
4. Inner cast under arithmetic inside outer cast:
```
SELECT CAST((CAST(event_timestamp AS LONG) / 1000) AS DOUBLE)
FROM my_table
LIMIT 1;
```
5. Filter / HAVING (same expression shape; failure is not SELECT-only):
```
SELECT *
FROM my_table
WHERE CAST(CAST(event_timestamp AS LONG) AS DOUBLE) > 0
LIMIT 1;
```
A query like CAST(CAST(x AS DOUBLE) AS LONG) may not fail the same way: the inner cast often uses types old servers already accept, and the outer LONG/BIGINT is still visited at the top-level CAST. The failure mode is specific to inner LONG→BIGINT (and similar aliases) hidden under another CAST before recursion into operand 0 is fixed.
--
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.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: [I] Fix CastTypeAliasRewriter to recurse into nested CAST operands for SSE [pinot]
Posted by "yashmayya (via GitHub)" <gi...@apache.org>.
yashmayya closed issue #18152: Fix CastTypeAliasRewriter to recurse into nested CAST operands for SSE
URL: https://github.com/apache/pinot/issues/18152
--
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