Skip to content

Conversation

@SavicStefan
Copy link

@SavicStefan SavicStefan commented Dec 12, 2025

What changes were proposed in this pull request?

Changed return value from Boolean to Option[Boolean] for newly introduced methods (from Spark 4.1.0) to be able to know whether dialect overrides method, since currently we don't know whether true means method is overridden and returns true or that is default implementation. For both methods, it does not make sense to have default true/false.

Changed that :

  • isObjectNotFoundException returns Option[Boolean], and the default implementation considers an exception as object not found when its SQLState starts with 42.
  • isSyntaxErrorBestEffort return Option[Boolean]

Why are the changes needed?

Before, if isObjectNotFound was not overridden (for example, in a custom Dialect), then when any other error was thrown that was not ‘table does not exist’, it would still be reported as a TableNotFound error, which is incorrect

Does this PR introduce any user-facing change?

Updated methods in JDBCDialects.

How was this patch tested?

Using existing JDBCTableCatalogSuite.

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

No.

@github-actions github-actions bot added the SQL label Dec 12, 2025
@SavicStefan SavicStefan marked this pull request as ready for review December 12, 2025 12:51
@Since("4.1.0")
def isObjectNotFoundException(e: SQLException): Boolean = true
def isObjectNotFoundException(e: SQLException): Option[Boolean] = {
Option(e.getSQLState).map(_.startsWith("42"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for reviewers: we want to have some generic implementation here that covers almost all SQL engines (42000 group usually means no access, no object found or syntax error on most engines, but since we don't expect syntax errors when table parameter is provided, we should be fine with this approach).

The most used callsite for tableExists now is in createRelation on write path. It checks whether tableExists, and it table does not exist, it goes on create table path. We should be fine even if we catch some other error than object not found in tableExists, since createTable would probably fail as well.

@urosstan-db
Copy link
Contributor

Can you add SPARK ticket, you can create it in SPARK jira

@urosstan-db
Copy link
Contributor

Can you update description with additional reason for change needed:

  • Changed return value from Boolean to Option[Boolean] for newly introduced methods (from Spark 4.1.0) to be able to know whether dialect overrides method, since currently we don't know whether true means method is overriden and returns true or that is default implementation. For both methods, it does not make sense to have default true/false.

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.

2 participants