-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-46410][SQL] Assign error classes/subclasses to JdbcUtils.classifyException #44358
Changes from 12 commits
50a7936
8c6158e
d7302f2
d3204c7
f9072ae
901c511
9b0090f
be74430
c9a23f5
707c212
d21fb1e
2e8eeb0
01a1a9c
0338fbc
06fbd90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1096,6 +1096,79 @@ | |
], | ||
"sqlState" : "38000" | ||
}, | ||
"FAILED_JDBC" : { | ||
"message" : [ | ||
"Failed the JDBC operation:" | ||
], | ||
"subClass" : { | ||
"ALTER_TABLE" : { | ||
"message" : [ | ||
"Alter the table <tableName>." | ||
] | ||
}, | ||
"CREATE_INDEX" : { | ||
"message" : [ | ||
"Create the index <indexName> in the <tableName> table." | ||
] | ||
}, | ||
"CREATE_NAMESPACE" : { | ||
"message" : [ | ||
"Create the namespace <namespace>." | ||
] | ||
}, | ||
"CREATE_NAMESPACE_COMMENT" : { | ||
"message" : [ | ||
"Create a comment on the namespace: <namespace>." | ||
] | ||
}, | ||
"CREATE_TABLE" : { | ||
"message" : [ | ||
"Create the table <tableName>." | ||
] | ||
}, | ||
"DROP_INDEX" : { | ||
"message" : [ | ||
"Drop the index <indexName> in the <tableName> table." | ||
] | ||
}, | ||
"DROP_NAMESPACE" : { | ||
"message" : [ | ||
"Drop the namespace <namespace>." | ||
] | ||
}, | ||
"GET_TABLES" : { | ||
"message" : [ | ||
"Get tables from the namespace: <namespace>." | ||
] | ||
}, | ||
"LIST_NAMESPACES" : { | ||
"message" : [ | ||
"List namespaces." | ||
] | ||
}, | ||
"NAMESPACE_EXISTS" : { | ||
"message" : [ | ||
"Check that the namespace <namespace> exists." | ||
] | ||
}, | ||
"REMOVE_NAMESPACE_COMMENT" : { | ||
"message" : [ | ||
"Remove a comment on the namespace: <namespace>." | ||
] | ||
}, | ||
"RENAME_TABLE" : { | ||
"message" : [ | ||
"Rename the table <oldName> to <newName>." | ||
] | ||
}, | ||
"TABLE_EXISTS" : { | ||
"message" : [ | ||
"Check that the table <tableName> exists." | ||
] | ||
} | ||
}, | ||
"sqlState" : "40000" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would be "transaction rollback" Is it obvious from the context what we are connecting to? Should we add some JDBC level context (URL?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Right.
Seems like, but what do you propose? to get
Should be if an user reads data from one JDBC datasource.
I can extract and pass
The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was proposing to replace 40000 with HV004. This example is interesting. How do we get a 42P07 with FAILED_JDBC errorclass? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@srielau I didn't get the logic why
From the doc https://www.postgresql.org/docs/14/errcodes-appendix.html and experiments. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I fat-fingered. Yes HV000 |
||
}, | ||
"FAILED_PARSE_STRUCT_TYPE" : { | ||
"message" : [ | ||
"Failed parsing struct: <raw>." | ||
|
@@ -6778,11 +6851,6 @@ | |
"pivot is not supported on a streaming DataFrames/Datasets" | ||
] | ||
}, | ||
"_LEGACY_ERROR_TEMP_3064" : { | ||
"message" : [ | ||
"<msg>" | ||
] | ||
}, | ||
"_LEGACY_ERROR_TEMP_3065" : { | ||
"message" : [ | ||
"<clazz>: <msg>" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
layout: global | ||
title: FAILED_JDBC error class | ||
displayTitle: FAILED_JDBC error class | ||
license: | | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You under the Apache License, Version 2.0 | ||
(the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--- | ||
|
||
SQLSTATE: 40000 | ||
|
||
Failed the JDBC operation: | ||
|
||
This error class has the following derived error classes: | ||
|
||
## ALTER_TABLE | ||
|
||
Alter the table `<tableName>`. | ||
|
||
## CREATE_INDEX | ||
|
||
Create the index `<indexName>` in the `<tableName>` table. | ||
|
||
## CREATE_NAMESPACE | ||
|
||
Create the namespace `<namespace>`. | ||
|
||
## CREATE_NAMESPACE_COMMENT | ||
|
||
Create a comment on the namespace: `<namespace>`. | ||
|
||
## CREATE_TABLE | ||
|
||
Create the table `<tableName>`. | ||
|
||
## DROP_INDEX | ||
|
||
Drop the index `<indexName>` in the `<tableName>` table. | ||
|
||
## DROP_NAMESPACE | ||
|
||
Drop the namespace `<namespace>`. | ||
|
||
## GET_TABLES | ||
|
||
Get tables from the namespace: `<namespace>`. | ||
|
||
## LIST_NAMESPACES | ||
|
||
List namespaces. | ||
|
||
## NAMESPACE_EXISTS | ||
|
||
Check that the namespace `<namespace>` exists. | ||
|
||
## REMOVE_NAMESPACE_COMMENT | ||
|
||
Remove a comment on the namespace: `<namespace>`. | ||
|
||
## RENAME_TABLE | ||
|
||
Rename the table `<oldName>` to `<newName>`. | ||
|
||
## TABLE_EXISTS | ||
|
||
Check that the table `<tableName>` exists. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1180,12 +1180,15 @@ object JdbcUtils extends Logging with SQLConfHelper { | |
} | ||
} | ||
|
||
def classifyException[T](message: String, dialect: JdbcDialect)(f: => T): T = { | ||
def classifyException[T]( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a breaking change, isn't it? JDBCDialect is a public developer API. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when was this API added? @beliefer do you know? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we should keep two versions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And how will you combine exceptions from the both versions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are no nested exception here. We pass a default error class to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So if a dialect can classify an exception, we will lose the error class which is actually worse? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also enable MiMa for this? I believe this is being skipped because it's under There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@cloud-fan A dialect can override proposed error class and make our default error class more precise using the driver specific info. And yes, the original error class will be lost.
@HyukjinKwon I made the modification because MiMa complained. Did you change MiMa to expect different behaviour? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think losing the original error class is bad. We added |
||
errorClass: String, | ||
messageParameters: Map[String, String], | ||
dialect: JdbcDialect)(f: => T): T = { | ||
try { | ||
f | ||
} catch { | ||
case e: SparkThrowable with Throwable => throw e | ||
case e: Throwable => throw dialect.classifyException(message, e) | ||
case e: Throwable => throw dialect.classifyException(e, errorClass, messageParameters) | ||
} | ||
} | ||
|
||
|
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.
FAILED_JDBC
->FAILED_JDBC_OPERATION
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.
Too long, does
_OPERATION
bring any benefits?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.
Just because
FAILED_JDBC
looks confused.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.
JDBC means Java Database Connectivity, the connectivity might fails at any time, ops or while establishing connections or while keeping it. For instance, this is real example:
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.
I guess the connectivity is not changed if
create index failed