Skip to content

[SPARK-52184][SQL] Wrap external engine JDBC syntax errors with a unified exception #50918

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

alekjarmov
Copy link
Contributor

@alekjarmov alekjarmov commented May 16, 2025

What changes were proposed in this pull request?

This PR introduces a unified mechanism for handling SQL syntax errors thrown by external JDBC engines. It does so by:

  • Adding a new error condition: JDBC_EXTERNAL_ENGINE_SYNTAX_ERROR.
  • Introducing a utility method in JdbcUtils to catch and rethrow SQLException with a more informative SparkException if the dialect recognizes it as a syntax error.
  • Extending multiple JdbcDialect implementations to provide best-effort syntax error detection via isSyntaxErrorBestEffort.
  • Updating integration test suites to include a new shared test that verifies the wrapping behavior.

Why are the changes needed?

Current behavior rethrows the error if it's a syntax error on the external engine. Having it wrapped in a Spark exception enables for easier data scince.

Does this PR introduce any user-facing change?

The users would get a better error message.

How was this patch tested?

Adding new integration tests.

Was this patch authored or co-authored using generative AI tooling?

Coauthored with GitHub Copilot.

@github-actions github-actions bot added the SQL label May 16, 2025
@@ -3873,6 +3873,12 @@
},
"sqlState" : "42000"
},
"JDBC_EXTERNAL_ENGINE_SYNTAX_ERROR" : {
"message" : [
"JDBC external engine syntax error in <source>."
Copy link
Member

@MaxGekk MaxGekk May 16, 2025

Choose a reason for hiding this comment

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

As I can see the source is limited set of strings:

  • "output schema resolution"
  • "query execution"

How about to make 2 sub-conditions of "JDBC_EXTERNAL_ENGINE_SYNTAX_ERROR" instead of the parameter? In this way, we could:

  1. avoid error text in source code. So, tech editors could modify the error-conditions.json w/o modifying/recompiling spark
  2. in the future we might have errors in different languages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants