Skip to content

refactor(query): simplify SQL parser error tracking#20194

Draft
KKould wants to merge 3 commits into
databendlabs:mainfrom
KKould:refactor/sql-parser-error-reporting
Draft

refactor(query): simplify SQL parser error tracking#20194
KKould wants to merge 3 commits into
databendlabs:mainfrom
KKould:refactor/sql-parser-error-reporting

Conversation

@KKould

@KKould KKould commented Jul 23, 2026

Copy link
Copy Markdown
Member

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

Summary

  • Remove optional parser Backtrace state and the disabled-first, reparse-on-error flow
  • Propagate the farthest active-branch error in a single parse
  • Derive expected tokens from complete token dispatches and keep SQL parser errors deterministic
  • Refresh parser error golden files for the new reporting model

Implementation

  • Simplify Input and Error by removing Backtrace and interior mutability
  • Merge same-position alternatives through the nom ParseError implementation
  • Generate first-token candidates from try_dispatch arms for complete dispatches
  • Guard speculative grammar branches with targeted lookahead and commit points
  • Keep optional and repeated parser behavior aligned with direct parser errors rather than retaining discarded branch failures

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - 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 (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe:)

This change is Reviewable

@github-actions github-actions Bot added the pr-refactor this PR changes the code base without new features or bugfix label Jul 23, 2026
@KKould KKould self-assigned this Jul 23, 2026
@KKould

KKould commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bbfb243f9d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/query/ast/src/parser/mod.rs Outdated
@KKould

KKould commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

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

Labels

pr-refactor this PR changes the code base without new features or bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant