Skip to content

Conversation

@SavicStefan
Copy link
Contributor

@SavicStefan SavicStefan commented Jan 16, 2026

What changes were proposed in this pull request?

Instead of explicitly calling tableExists in JDBCTableCatalog.loadTable(...), this change now detects whether a table exists by catching SQLException from getQueryOutputSchema and checking it with the dialect-specific isObjectNotFoundException method.

By checking isObjectNotFoundException before isSyntaxErrorBestEffort, the code can reliably distinguish between the case where table does not exists and other SQL syntax errors. This order is important because when a table does not exist, the exception raised can also match the criteria for isSyntaxErrorBestEffort.

Why are the changes needed?

This change removes the redundant tableExists call, since we can determine whether a table exists based on the error thrown from getQueryOutputSchema.

With this change now only makes one JDBC API call instead of two, improving efficiency by eliminating the need for a separate table existence check.

Does this PR introduce any user-facing change?

No

How was this patch tested?

It was tested using existing and new tests in JDBCTableCatalogSuite.

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

No.

@github-actions
Copy link

github-actions bot commented Jan 16, 2026

JIRA Issue Information

=== Improvement SPARK-55065 ===
Summary: Avoid making two JDBC API calls
Assignee: None
Status: Open
Affected: ["4.2.0","4.1.1"]


This comment was automatically generated by GitHub Actions

@github-actions github-actions bot added the SQL label Jan 16, 2026
@SavicStefan SavicStefan changed the title Stefan savic data/jdbc/two api calls [SPARK-55065] Avoid making two JDBC API calls Jan 16, 2026
*
* @return A StructType giving the table's Catalyst schema.
* @throws java.sql.SQLException if the table specification is garbage.
* @throws java.sql.SQLException if the table contains an unsupported type.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add new params to docs, including conn?

@SavicStefan SavicStefan requested a review from cloud-fan January 19, 2026 09:21
@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 6167ef2 Jan 19, 2026
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