[SPARK-49730][SQL] classify syntax errors for pgsql, mysql, sqlserver and h2 #48182
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
In this PR I propose that we add classification of JDBC driver exception that represent syntax errors on external databases.
Queries generated from Spark that are sent to connectors should never have syntax error, and always indicate to a bug in code.
Having this classification would greatly help in identifying bugs faster and improving quality.
Documentation about error codes for syntax errors:
https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors-0-to-999?view=sql-server-ver16
https://www.postgresql.org/docs/current/errcodes-appendix.html
https://mariadb.com/kb/en/mariadb-error-code-reference/
https://www.h2database.com/javadoc/org/h2/api/ErrorCode.html
Why are the changes needed?
Does this PR introduce any user-facing change?
Yes, previously customers would get
FAILED_JDBC. UNCLASSIFIED
or internal error when syntax error occurs in JDBC, whereas they will now getFAILED_JDBC.SYNTAX_ERROR
How was this patch tested?
Integration tests
Was this patch authored or co-authored using generative AI tooling?
No