Skip to content

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

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

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
Copy link

github-actions bot commented May 6, 2025

Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale PR has not had any activity for some time label May 6, 2025
@github-actions github-actions bot closed this May 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sql SQL Planner Stale PR has not had any activity for some time
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attach Diagnostic to syntax errors
2 participants