Skip to content

fix: sparksql lateral view parse tree for multiple column alias (#4980) - #3076

Open
benfdking wants to merge 1 commit into
port/sqlfluff-4967from
port/sqlfluff-4980
Open

fix: sparksql lateral view parse tree for multiple column alias (#4980)#3076
benfdking wants to merge 1 commit into
port/sqlfluff-4967from
port/sqlfluff-4980

Conversation

@benfdking

Copy link
Copy Markdown
Collaborator

Stacked on sqruff #3074. Merge #3074 first.

Base PR: #3074

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 — mirroring SQLFluff's OneOf grammar. Previously LATERAL VIEW ... AS c1, c2 mis-parsed c2 as a spurious comma-separated FROM-clause table reference; it is now correctly a column alias inside the lateral view clause.
  • Regenerated the select_from_lateral_view and select_lateral_view_supported_tvf YAML parse trees. The new trees match SQLFluff's expected output (aliases become direct keyword: AS / naked_identifier children rather than an alias_expression wrapper).
  • Advanced .sqlfluff-sha to 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 (bazel test //...) could not run in this environment: the org egress policy returns 403 for bcr.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

## 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
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Benchmark for a9f85e8

Click to view benchmark
Test Base PR %
DepthMap::from_parent 117.5±1.24µs 122.0±2.97µs +3.83%
fix_complex_query 13.4±0.14ms 13.4±0.18ms 0.00%
fix_superlong 154.9±7.01ms 133.1±10.21ms -14.07%
parse_complex_query 4.2±0.13µs 4.2±0.06µs 0.00%
parse_expression_recursion 7.0±0.06µs 6.9±0.16µs -1.43%
parse_simple_query 1034.4±32.58ns 1045.9±28.21ns +1.11%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants