This is an automated email from the ASF dual-hosted git repository. maxgekk pushed a commit to branch branch-3.4 in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.4 by this push: new b3ebb69e387 [SPARK-42232][SQL] Rename error class: `UNSUPPORTED_FEATURE.JDBC_TRANSACTION` b3ebb69e387 is described below commit b3ebb69e3874dc9a30c8b74e3ab6b673fa378e73 Author: itholic <haejoon....@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 <haejoon....@databricks.com> Signed-off-by: Max Gekk <max.g...@gmail.com> (cherry picked from commit 1cae312a74a2e6e2d82e87c09c208380be1a09fb) Signed-off-by: Max Gekk <max.g...@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 e1598a4bc7b..92a81e78fd9 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-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org