Skip to content

fix(ast): avoid round-trip parser panic for nested joins#19605

Open
sundy-li wants to merge 1 commit intodatabendlabs:mainfrom
sundy-li:issue-19571-20260324-2007
Open

fix(ast): avoid round-trip parser panic for nested joins#19605
sundy-li wants to merge 1 commit intodatabendlabs:mainfrom
sundy-li:issue-19571-20260324-2007

Conversation

@sundy-li
Copy link
Copy Markdown
Member

@sundy-li sundy-li commented Mar 24, 2026

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Fixes #19571

Summary

  • stop the debug-only SQL round-trip check from panicking when nested join grouping cannot be reparsed from the pretty-printed SQL
  • keep the original parse result and emit a warning instead, so parser quality checks do not crash the server
  • add a regression test for grouped nested joins with separate join conditions

Changes

  1. Update src/query/ast/src/parser/parser.rs so the debug round-trip validation returns an error message instead of panicking/asserting.
  2. Log the round-trip failure with log::warn! and keep parse_sql() returning the original parsed statement.
  3. Add integration coverage in src/query/ast/tests/it/display.rs for nested joins that currently lose grouping when displayed.

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Pair with the reviewer to explain why

Validation:

  • cargo fmt --all --check
  • cargo test -p databend-common-ast
  • cargo clippy -p databend-common-ast --all-targets -- -D warnings

Type of change

  • Bug fix

This change is Reviewable

@github-actions github-actions bot added the pr-bugfix this PR patches a bug in codebase label Mar 24, 2026
@sundy-li sundy-li added agent-reviewable Ready for agent review agent-approved Approved by agent and removed agent-reviewable Ready for agent review labels Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-approved Approved by agent pr-bugfix this PR patches a bug in codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL Parser panics on nested JOIN with multiple conditions

1 participant