feat(calcite): fix visitor issues for V2 SQL AST integration#25
Draft
dai-chen wants to merge 1 commit into
Draft
feat(calcite): fix visitor issues for V2 SQL AST integration#25dai-chen wants to merge 1 commit into
dai-chen wants to merge 1 commit into
Conversation
ebf6089 to
3acba66
Compare
Fix CalciteRelNodeVisitor/RexNodeVisitor gaps surfaced when routing the V2 SQL AST through the unified query path: - expandProjectFields: add Alias case so already-computed aggregates are referenced by schema name (was throwing "Unexpected expression type: Alias"). - visitLimit: new override for SQL LIMIT/OFFSET. PPL is unaffected (uses Head node). - visitAggregation: fix BUCKET_NULLABLE NPE when SQL GROUP BY produces an Aggregation without that arg. Use getOrDefault(..., Literal.TRUE). - visitRelationSubquery: new override for derived tables in FROM (SELECT ... FROM (SELECT ...) AS t). - visitValues: handle (a) dual-table [[]] for SELECT without FROM and (b) non-empty inline VALUES via relBuilder.values(fieldNames, flat). - visitWindowFunction: handle AggregateFunction (V2 SQL) + DISTINCT + OVER ORDER BY (was hardcoded to List.of()). Register ROW_NUMBER/RANK/DENSE_RANK in WINDOW_FUNC_MAPPING and bypass aggregate validation for these pure window functions. Add a makeOver overload with a distinct parameter (old signature delegates with false to preserve PPL behavior). Add nine tests in UnifiedQueryPlannerSqlTest, one per fix. Verified zero PPL regressions across 2300+ existing tests. Signed-off-by: Chen Dai <daichen@amazon.com>
3acba66 to
5752600
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix four CalciteRelNodeVisitor/RexNodeVisitor gaps surfaced when routing the V2 SQL AST through the unified query path:
SELECT COUNT(*) AS cnt ... GROUP BY ...previously crashed with "Unexpected expression type: Alias". Reference already-computed aggregates by schema name instead of re-analyzing.getOrDefault(..., Literal.TRUE)to match Analyzer.java.Add seven tests in UnifiedQueryPlannerSqlTest, one per fix. Verified zero PPL regressions across 2300+ existing tests.
Description
[Describe what this change achieves]
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
--signoffor-s.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.