-
Notifications
You must be signed in to change notification settings - Fork 29k
Changed isObjectNotFoundException and isSyntaxErrorBestEffort to be O… #53456
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
base: master
Are you sure you want to change the base?
Conversation
sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala
Outdated
Show resolved
Hide resolved
sql/core/src/main/scala/org/apache/spark/sql/jdbc/TeradataDialect.scala
Outdated
Show resolved
Hide resolved
sql/core/src/main/scala/org/apache/spark/sql/jdbc/H2Dialect.scala
Outdated
Show resolved
Hide resolved
| @Since("4.1.0") | ||
| def isObjectNotFoundException(e: SQLException): Boolean = true | ||
| def isObjectNotFoundException(e: SQLException): Option[Boolean] = { | ||
| Option(e.getSQLState).map(_.startsWith("42")) |
There was a problem hiding this comment.
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.
|
Can you add SPARK ticket, you can create it in SPARK jira |
|
Can you update description with additional reason for change needed:
|
What changes were proposed in this pull request?
Changed return value from
BooleantoOption[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 :
isObjectNotFoundExceptionreturnsOption[Boolean], and the default implementation considers an exception as object not found when itsSQLStatestarts with 42.isSyntaxErrorBestEffortreturnOption[Boolean]Why are the changes needed?
Before, if
isObjectNotFoundwas 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 incorrectDoes 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.