Skip to content

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

Closed
alekjarmov wants to merge 5 commits into
apache:masterfrom
alekjarmov:wrap-external-engine-errors
Closed

alekjarmov wants to merge 5 commits into
apache:masterfrom
alekjarmov:wrap-external-engine-errors

Conversation

@alekjarmov

@alekjarmov alekjarmov commented May 16, 2025 •

Copy link
Copy Markdown
Contributor

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.
  • 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
@MaxGekk

MaxGekk commented May 19, 2025

Copy link
Copy Markdown
Member

@alekjarmov Could you fix formatting, please:

[info] SparkThrowableSuite:
[info] - No duplicate error classes (27 milliseconds)
[info] - Error conditions are correctly formatted *** FAILED *** (143 milliseconds)

just re-generate the json file:

$ SPARK_GENERATE_GOLDEN_FILES=1 build/sbt "core/testOnly *SparkThrowableSuite -- -t \"Error conditions are correctly formatted\""

@alekjarmov
alekjarmov force-pushed the wrap-external-engine-errors branch from 6898200 to 8b143e5 Compare May 19, 2025 08:53
@alekjarmov
alekjarmov force-pushed the wrap-external-engine-errors branch from 8b143e5 to 2aacaf9 Compare May 19, 2025 09:43
@alekjarmov

Copy link
Copy Markdown
Contributor Author

@cloud-fan Could you merge it please if everything is ok?

},
"JDBC_EXTERNAL_ENGINE_SYNTAX_ERROR" : {
"message" : [
"JDBC external engine syntax error."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is it possible to always provide the compiled JDBC SQL text?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I modified the error message to include the query.

@cloud-fan

Copy link
Copy Markdown
Contributor

The last commit just modified the version number in @Since, no need to run tests again. I'm merging it to master, thanks!

@cloud-fan cloud-fan closed this in e7627b1 May 20, 2025
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