You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ma...@apache.org on 2023/02/02 09:16:49 UTC
[spark] branch master updated: [SPARK-42232][SQL] Rename error class: `UNSUPPORTED_FEATURE.JDBC_TRANSACTION`
This is an automated email from the ASF dual-hosted git repository.
maxgekk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 1cae312a74a [SPARK-42232][SQL] Rename error class: `UNSUPPORTED_FEATURE.JDBC_TRANSACTION`
1cae312a74a is described below
commit 1cae312a74a2e6e2d82e87c09c208380be1a09fb
Author: itholic <ha...@databricks.com>
AuthorDate: Thu Feb 2 12:16:35 2023 +0300
[SPARK-42232][SQL] Rename error class: `UNSUPPORTED_FEATURE.JDBC_TRANSACTION`
### What changes were proposed in this pull request?
This PR proposes to rename error class `UNSUPPORTED_FEATURE.JDBC_TRANSACTION` into `UNSUPPORTED_FEATURE.MULTI_ACTION_ALTER`
### Why are the changes needed?
To provide precious and better error message to end-users.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Fixed UTs.
Closes #39799 from itholic/JDBC_TRANSACTION.
Authored-by: itholic <ha...@databricks.com>
Signed-off-by: Max Gekk <ma...@gmail.com>
---
core/src/main/resources/error/error-classes.json | 10 +++++-----
.../org/apache/spark/sql/errors/QueryExecutionErrors.scala | 6 +++---
.../spark/sql/execution/datasources/jdbc/JdbcUtils.scala | 2 +-
.../apache/spark/sql/errors/QueryExecutionErrorsSuite.scala | 8 ++++----
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/core/src/main/resources/error/error-classes.json b/core/src/main/resources/error/error-classes.json
index 14ab0c59c30..178eda8ce11 100644
--- a/core/src/main/resources/error/error-classes.json
+++ b/core/src/main/resources/error/error-classes.json
@@ -1522,11 +1522,6 @@
"INSERT INTO <tableName> with IF NOT EXISTS in the PARTITION spec."
]
},
- "JDBC_TRANSACTION" : {
- "message" : [
- "The target JDBC server does not support transactions and can only support ALTER TABLE with a single action."
- ]
- },
"LATERAL_COLUMN_ALIAS_IN_AGGREGATE_FUNC" : {
"message" : [
"Referencing a lateral column alias <lca> in the aggregate function <aggFunc>."
@@ -1567,6 +1562,11 @@
"Multiple bucket TRANSFORMs."
]
},
+ "MULTI_ACTION_ALTER" : {
+ "message" : [
+ "The target JDBC server hosting table <tableName> does not support ALTER TABLE with multiple actions. Split the ALTER TABLE up into individual actions to avoid this error."
+ ]
+ },
"NATURAL_CROSS_JOIN" : {
"message" : [
"NATURAL CROSS JOIN."
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
index 82429ae1141..c64c26e510b 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
@@ -1039,10 +1039,10 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase {
messageParameters = Map("n" -> n.toString(), "jdbcNumPartitions" -> jdbcNumPartitions))
}
- def transactionUnsupportedByJdbcServerError(): Throwable = {
+ def multiActionAlterError(tableName: String): Throwable = {
new SparkSQLFeatureNotSupportedException(
- errorClass = "UNSUPPORTED_FEATURE.JDBC_TRANSACTION",
- messageParameters = Map.empty[String, String])
+ errorClass = "UNSUPPORTED_FEATURE.MULTI_ACTION_ALTER",
+ messageParameters = Map("tableName" -> tableName))
}
def dataTypeUnsupportedYetError(dataType: DataType): SparkUnsupportedOperationException = {
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
index 76599c53db9..4b0d461e237 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
@@ -947,7 +947,7 @@ object JdbcUtils extends Logging with SQLConfHelper {
metaData.getDatabaseMajorVersion)(0))
} else {
if (!metaData.supportsTransactions) {
- throw QueryExecutionErrors.transactionUnsupportedByJdbcServerError()
+ throw QueryExecutionErrors.multiActionAlterError(tableName)
} else {
conn.setAutoCommit(false)
val statement = conn.createStatement
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala
index 70311a2f7b8..c679e4f707f 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala
@@ -696,8 +696,8 @@ class QueryExecutionErrorsSuite
}
}
- test("UNSUPPORTED_FEATURE.JDBC_TRANSACTION: the target JDBC server does not support " +
- "transactions and can only support ALTER TABLE with a single action") {
+ test("UNSUPPORTED_FEATURE.MULTI_ACTION_ALTER: The target JDBC server hosting table " +
+ "does not support ALTER TABLE with multiple actions.") {
withTempDir { tempDir =>
val url = s"jdbc:h2:${tempDir.getCanonicalPath};user=testUser;password=testPass"
Utils.classForName("org.h2.Driver")
@@ -751,8 +751,8 @@ class QueryExecutionErrorsSuite
checkError(
exception = e.getCause.asInstanceOf[SparkSQLFeatureNotSupportedException],
- errorClass = "UNSUPPORTED_FEATURE.JDBC_TRANSACTION",
- parameters = Map.empty)
+ errorClass = "UNSUPPORTED_FEATURE.MULTI_ACTION_ALTER",
+ parameters = Map("tableName" -> "\"test\".\"people\""))
JdbcDialects.unregisterDialect(testH2DialectUnsupportedJdbcTransaction)
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org