fix: sparksql lateral view parse tree for multiple column alias (#4980) - #3076
Open
benfdking wants to merge 1 commit into
Open
fix: sparksql lateral view parse tree for multiple column alias (#4980)#3076benfdking wants to merge 1 commit into
benfdking wants to merge 1 commit into
Conversation
## Summary - Rewrote `LateralViewClauseSegment` in the sparksql dialect to accept a table name followed by an optional (`AS`) delimited list of column aliases, or a bare (`AS`) delimited list — matching SQLFluff's OneOf grammar so `LATERAL VIEW ... AS c1, c2` parses c2 as a column alias instead of a spurious FROM-clause table reference. - Regenerated the `select_from_lateral_view` and `select_lateral_view_supported_tvf` YAML parse trees. Ported from SQLFluff eacd20ac144148ccce5db1b733bb220a2f80c812 sqlfluff/sqlfluff#4980 sqlfluff/sqlfluff@eacd20a Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YRMKon6PZkQkcZNzguq5qh
Contributor
Benchmark for a9f85e8Click to view benchmark
|
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.
Summary
LateralViewClauseSegmentin the sparksql dialect to accept a table name followed by an optional (AS) delimited list of column aliases, or a bare (AS) delimited list — mirroring SQLFluff'sOneOfgrammar. PreviouslyLATERAL VIEW ... AS c1, c2mis-parsedc2as a spurious comma-separated FROM-clause table reference; it is now correctly a column alias inside the lateral view clause.select_from_lateral_viewandselect_lateral_view_supported_tvfYAML parse trees. The new trees match SQLFluff's expected output (aliases become directkeyword: AS/naked_identifierchildren rather than analias_expressionwrapper)..sqlfluff-shato the ported commit.The upstream SQL fixture additions were already present in this stack, so this change is the grammar fix plus the regenerated parse trees.
Testing
cargo build✅cargo test(full workspace, incl. sparksql dialect fixture tests) ✅bazel test //...) could not run in this environment: the org egress policy returns 403 forbcr.bazel.build(Bazel Central Registry), so the module graph can't resolve locally. CI runs the Bazel targets on GitHub. The hermetic equivalent (cargo test) passes.Ported from SQLFluff eacd20ac144148ccce5db1b733bb220a2f80c812
sqlfluff/sqlfluff#4980
sqlfluff/sqlfluff@eacd20a
Generated by Claude Code