Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve SQL syntax error messages in parser (#14437) #14986

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

khushishukla2813
Copy link

Which issue does this PR close?

Closes #14437

Rationale for this change

The current SQL syntax error messages in DataFusion lack detailed context, making debugging difficult for users.
This PR improves error reporting by:
Showing unexpected tokens in the error message.
Displaying exact line and column numbers for better debugging.
Providing helpful hints when possible.

What changes are included in this PR?

Enhanced parser_err! macro** to include token details, line, and column.
Modified expected function
to return more precise error locations.
Added a test case (test_parser_error_message)
to verify the improved error messages.

Are these changes tested?

Yes ✅

  • A new test case was added in parser.rs to check:
    • Correct error message format.
    • Proper token identification in error messages.
    • Correct line and column output.

Are there any user-facing changes?

Yes ✅

  • Error messages now provide clearer debugging information.
  • No breaking changes to existing APIs.

@github-actions github-actions bot added the sql SQL Planner label Mar 3, 2025
@alamb
Copy link
Contributor

alamb commented Mar 3, 2025

Thanks @khushishukla2813 -- looks like this one needs some test changes. Marking as a draft for now while you work on the CI failures

@alamb alamb marked this pull request as draft March 3, 2025 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attach Diagnostic to syntax errors
2 participants