Skip to content
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-50751][SQL] Assign appropriate error condition for _LEGACY_ERROR_TEMP_1305: UNSUPPORTED_TABLE_CHANGE_IN_JDBC_CATALOG #49395

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions common/utils/src/main/resources/error/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6007,6 +6007,12 @@
},
"sqlState" : "0A000"
},
"UNSUPPORTED_TABLE_CHANGE_IN_JDBC_CATALOG" : {
"message" : [
"The table change <change> is not supported for the JDBC catalog on table <tableName>. Supported changes include: AddColumn, RenameColumn, DeleteColumn, UpdateColumnType, UpdateColumnNullability."
],
"sqlState" : "42000"
},
"UNSUPPORTED_TYPED_LITERAL" : {
"message" : [
"Literals of the type <unsupportedType> are not supported. Supported types are <supportedTypes>."
Expand Down Expand Up @@ -7175,11 +7181,6 @@
"Unable to find the column `<colName>` given [<actualColumns>]."
]
},
"_LEGACY_ERROR_TEMP_1305" : {
"message" : [
"Unsupported TableChange <change> in JDBC catalog."
]
},
"_LEGACY_ERROR_TEMP_1306" : {
"message" : [
"There is a 'path' or 'paths' option set and load() is called with path parameters. Either remove the path option if it's the same as the path parameter, or add it to the load() parameter if you do want to read multiple paths. To ignore this check, set '<config>' to 'true'."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3317,10 +3317,13 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat
new NoSuchTableException(ident)
}

def unsupportedTableChangeInJDBCCatalogError(change: TableChange): Throwable = {
def unsupportedTableChangeInJDBCCatalogError(
change: TableChange, tableName: String): Throwable = {
val sanitizedTableName = tableName.replaceAll("\"", "")
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1305",
messageParameters = Map("change" -> change.toString))
errorClass = "UNSUPPORTED_TABLE_CHANGE_IN_JDBC_CATALOG",
messageParameters = Map(
"change" -> change.toString, "tableName" -> toSQLId(sanitizedTableName)))
}

def pathOptionNotSetCorrectlyWhenReadingError(): Throwable = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ abstract class JdbcDialect extends Serializable with Logging {
val name = updateNull.fieldNames
updateClause += getUpdateColumnNullabilityQuery(tableName, name(0), updateNull.nullable())
case _ =>
throw QueryCompilationErrors.unsupportedTableChangeInJDBCCatalogError(change)
throw QueryCompilationErrors.unsupportedTableChangeInJDBCCatalogError(change, tableName)
}
}
updateClause.result()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,11 @@ class JDBCTableCatalogSuite extends QueryTest with SharedSparkSession {
exception = intercept[AnalysisException] {
sql(s"ALTER TABLE $tableName ALTER COLUMN ID COMMENT 'test'")
},
condition = "_LEGACY_ERROR_TEMP_1305",
parameters = Map("change" ->
"org.apache.spark.sql.connector.catalog.TableChange\\$UpdateColumnComment.*"),
condition = "UNSUPPORTED_TABLE_CHANGE_IN_JDBC_CATALOG",
parameters = Map(
"change" -> "org.apache.spark.sql.connector.catalog.TableChange\\$UpdateColumnComment.*",
"tableName" -> "`test`.`alt_table`"
),
matchPVals = true)
// Update comment for not existing column
val sqlText = s"ALTER TABLE $tableName ALTER COLUMN bad_column COMMENT 'test'"
Expand Down
Loading