Skip to content

[SPARK-37940][SQL]update error mechanism to fully SparkThrowable #51108

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
121 changes: 67 additions & 54 deletions common/utils/src/main/resources/error/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3369,6 +3369,24 @@
},
"sqlState" : "42601"
},
"INVALID_PARTITION_COLUMN" : {
"message" : [
"<partKey> is not a partition column. Partition columns are <partitionColumns>."
],
"sqlState" : "42000"
},
"INVALID_PARTITION_SPEC" : {
"message" : [
"Partition spec is invalid. <details>."
],
"sqlState" : "42000"
},
"INVALID_PARTITION_SPEC_KEYS" : {
"message" : [
"Partition spec is invalid. The spec (<specKeys>) must match the partition spec (<partitionColumnNames>) defined in table '<tableName>'."
],
"sqlState" : "42000"
},
"INVALID_PARTITION_VALUE" : {
"message" : [
"Failed to cast value <value> to data type <dataType> for partition column <columnName>. Ensure the value matches the expected data type for this partition column."
Expand Down Expand Up @@ -4079,6 +4097,14 @@
],
"sqlState" : "42601"
},
"MISMATCHED_TABLE_PARTITION_COLUMN" : {
"message" : [
"Specified partitioning does not match that of the existing table <tableName>.",
"Specified partition columns: [<specifiedPartCols>].",
"Existing partition columns: [<existingPartCols>]."
],
"sqlState" : "42000"
},
"MISSING_AGGREGATION" : {
"message" : [
"The non-aggregating expression <expression> is based on columns which are not participating in the GROUP BY clause.",
Expand Down Expand Up @@ -4123,12 +4149,24 @@
],
"sqlState" : "HY000"
},
"MISSING_STATIC_PARTITION_COLUMN" : {
"message" : [
"Missing static partition column <staticName>."
],
"sqlState" : "42000"
},
"MISSING_WINDOW_SPECIFICATION" : {
"message" : [
"Window specification is not defined in the WINDOW clause for <windowName>. For more information about WINDOW clauses, please refer to '<docroot>/sql-ref-syntax-qry-select-window.html'."
],
"sqlState" : "42P20"
},
"MULTIPLE_PARTITION_COLUMN_VALUES_SPECIFIED" : {
"message" : [
"Partition column <partColumn> have multiple values specified, <values>. Please only specify a single value."
],
"sqlState" : "42000"
},
"MULTIPLE_PRIMARY_KEYS" : {
"message" : [
"Multiple primary keys are defined: <columns>. Please ensure that only one primary key is defined for the table."
Expand Down Expand Up @@ -4582,6 +4620,12 @@
],
"sqlState" : "428FT"
},
"PARTITION_COLUMN_NOT_SPECIFIED" : {
"message" : [
"Failed to resolve the schema for <format> for the partition column: <partitionColumn>. It must be specified manually."
],
"sqlState" : "42000"
},
"PARTITIONS_NOT_FOUND" : {
"message" : [
"The partition(s) <partitionList> cannot be found in table <tableName>.",
Expand All @@ -4590,6 +4634,12 @@
],
"sqlState" : "428FT"
},
"PARTITION_NOT_SPECIFY_LOCATION_URI" : {
"message" : [
"Partition [<specString>] did not specify locationUri."
],
"sqlState" : "42000"
},
"PARTITION_COLUMN_NOT_FOUND_IN_SCHEMA" : {
"message" : [
"Partition column <column> not found in schema <schema>. Please provide the existing column for partitioning."
Expand Down Expand Up @@ -5901,6 +5951,11 @@
"ALTER TABLE SET SERDE is not supported for table <tableName> created with the datasource API. Consider using an external Hive table or updating the table properties with compatible options for your table format."
]
},
"ALTER_TABLE_SET_LOCATION_WITH_PARTITION" : {
"message" : [
"ALTER TABLE SET LOCATION does not support partition for v2 tables."
]
},
"ANALYZE_UNCACHED_TEMP_VIEW" : {
"message" : [
"The ANALYZE TABLE FOR COLUMNS command can operate on temporary views that have been cached already. Consider to cache the view <viewName>."
Expand Down Expand Up @@ -5966,6 +6021,11 @@
"DESC TABLE COLUMN for a specific partition."
]
},
"DESC_PARTITION_FOR_V2_TABLE" : {
"message" : [
"DESCRIBE does not support partition for v2 tables."
]
},
"DROP_DATABASE" : {
"message" : [
"Drop the default database <database>."
Expand Down Expand Up @@ -6193,6 +6253,11 @@
"State TTL with <stateStoreProvider> is not supported. Please use RocksDBStateStoreProvider."
]
},
"TABLE_MANAGEMENT" : {
"message" : [
"Table does not support <cmd>: <table>."
]
},
"TABLE_OPERATION" : {
"message" : [
"Table <tableName> does not support <operation>. Please check the current catalog and namespace to make sure the qualified table name is expected, and also check the catalog implementation which is configured by \"spark.sql.catalog\"."
Expand Down Expand Up @@ -7015,11 +7080,6 @@
"Gap duration expression used in session window must be CalendarIntervalType, but got <dt>."
]
},
"_LEGACY_ERROR_TEMP_1045" : {
"message" : [
"ALTER TABLE SET LOCATION does not support partition for v2 tables."
]
},
"_LEGACY_ERROR_TEMP_1046" : {
"message" : [
"Join strategy hint parameter should be an identifier or string but was <unsupported> (<class>)."
Expand Down Expand Up @@ -7095,11 +7155,6 @@
"RENAME TEMPORARY VIEW from '<oldName>' to '<newName>': cannot specify database name '<db>' in the destination table."
]
},
"_LEGACY_ERROR_TEMP_1076" : {
"message" : [
"Partition spec is invalid. <details>."
]
},
"_LEGACY_ERROR_TEMP_1079" : {
"message" : [
"Resource Type '<resourceType>' is not supported."
Expand All @@ -7115,9 +7170,9 @@
"Table <identifier> did not specify locationUri."
]
},
"_LEGACY_ERROR_TEMP_1082" : {
"_LEGACY_ERROR_TEMP_1083" : {
"message" : [
"Partition [<specString>] did not specify locationUri."
"Number of buckets should be greater than 0 but less than or equal to bucketing.maxBuckets (`<bucketingMaxBuckets>`). Got `<numBuckets>`."
]
},
"_LEGACY_ERROR_TEMP_1089" : {
Expand Down Expand Up @@ -7165,11 +7220,6 @@
"Cannot delete from table <table> where <filters>."
]
},
"_LEGACY_ERROR_TEMP_1111" : {
"message" : [
"DESCRIBE does not support partition for v2 tables."
]
},
"_LEGACY_ERROR_TEMP_1114" : {
"message" : [
"The streaming sources in a query do not have a common supported execution mode.",
Expand All @@ -7182,11 +7232,6 @@
"Unsupported NamespaceChange <changes> in JDBC catalog."
]
},
"_LEGACY_ERROR_TEMP_1121" : {
"message" : [
"Table does not support <cmd>: <table>."
]
},
"_LEGACY_ERROR_TEMP_1122" : {
"message" : [
"Table <table> is not a row-level operation table."
Expand All @@ -7207,11 +7252,6 @@
"Invalid partitionExprs specified: <sortOrders> For range partitioning use REPARTITION_BY_RANGE instead."
]
},
"_LEGACY_ERROR_TEMP_1128" : {
"message" : [
"Failed to resolve the schema for <format> for the partition column: <partitionColumn>. It must be specified manually."
]
},
"_LEGACY_ERROR_TEMP_1132" : {
"message" : [
"A schema needs to be specified when using <className>."
Expand Down Expand Up @@ -7270,16 +7310,6 @@
"The data to be inserted needs to have the same number of partition columns as the target table: target table has <targetSize> partition column(s) but the inserted data has <providedPartitionsSize> partition columns specified."
]
},
"_LEGACY_ERROR_TEMP_1145" : {
"message" : [
"<partKey> is not a partition column. Partition columns are <partitionColumns>."
]
},
"_LEGACY_ERROR_TEMP_1146" : {
"message" : [
"Partition column <partColumn> have multiple values specified, <values>. Please only specify a single value."
]
},
"_LEGACY_ERROR_TEMP_1147" : {
"message" : [
"The ordering of partition columns is <partColumns>. All partition columns having constant values need to appear before other partition columns that do not have an assigned constant value."
Expand All @@ -7295,11 +7325,6 @@
"Fail to resolve data source for the table <table> since the table serde property has the duplicated key <key> with extra options specified for this scan operation. To fix this, you can rollback to the legacy behavior of ignoring the extra options by setting the config <config> to `false`, or address the conflicts of the same config."
]
},
"_LEGACY_ERROR_TEMP_1155" : {
"message" : [
"Partition column `<col>` not found in schema <schemaCatalog>."
]
},
"_LEGACY_ERROR_TEMP_1158" : {
"message" : [
"Saving data into a view is not allowed."
Expand All @@ -7325,13 +7350,6 @@
"Cannot resolve '<col>' given input columns: [<inputColumns>]."
]
},
"_LEGACY_ERROR_TEMP_1163" : {
"message" : [
"Specified partitioning does not match that of the existing table <tableName>.",
"Specified partition columns: [<specifiedPartCols>].",
"Existing partition columns: [<existingPartCols>]."
]
},
"_LEGACY_ERROR_TEMP_1164" : {
"message" : [
"Specified bucketing does not match that of the existing table <tableName>.",
Expand Down Expand Up @@ -7544,11 +7562,6 @@
"Decimal scale (<scale>) cannot be greater than precision (<precision>)."
]
},
"_LEGACY_ERROR_TEMP_1232" : {
"message" : [
"Partition spec is invalid. The spec (<specKeys>) must match the partition spec (<partitionColumnNames>) defined in table '<tableName>'."
]
},
"_LEGACY_ERROR_TEMP_1237" : {
"message" : [
"The list of partition columns with values in partition specification for table '<table>' in database '<database>' is not a prefix of the list of partition columns defined in the table schema. Expected a prefix of [<schemaColumns>], but got [<specColumns>]."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,9 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat
}

def missingStaticPartitionColumn(staticName: String): Throwable = {
SparkException.internalError(s"Unknown static partition column: $staticName.")
new AnalysisException(
errorClass = "MISSING_STATIC_PARTITION_COLUMN",
messageParameters = Map("staticName" -> toSQLId(staticName)))
}

def staticPartitionInUserSpecifiedColumnsError(staticName: String): Throwable = {
Expand Down Expand Up @@ -974,7 +976,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat

def alterV2TableSetLocationWithPartitionNotSupportedError(): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1045",
errorClass = "UNSUPPORTED_FEATURE.ALTER_TABLE_SET_LOCATION_WITH_PARTITION",
messageParameters = Map.empty)
}

Expand Down Expand Up @@ -1233,7 +1235,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat

def invalidPartitionSpecError(details: String): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1076",
errorClass = "INVALID_PARTITION_SPEC",
messageParameters = Map("details" -> details))
}

Expand Down Expand Up @@ -1270,7 +1272,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat

def partitionNotSpecifyLocationUriError(specString: String): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1082",
errorClass = "PARTITION_NOT_SPECIFY_LOCATION_URI",
messageParameters = Map("specString" -> specString))
}

Expand Down Expand Up @@ -1487,7 +1489,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat

def describeDoesNotSupportPartitionForV2TablesError(): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1111",
errorClass = "UNSUPPORTED_FEATURE.DESC_PARTITION_FOR_V2_TABLE",
messageParameters = Map.empty)
}

Expand Down Expand Up @@ -1585,7 +1587,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat

private def tableDoesNotSupportError(cmd: String, table: Table): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1121",
errorClass = "UNSUPPORTED_FEATURE.TABLE_MANAGEMENT",
messageParameters = Map(
"cmd" -> cmd,
"table" -> table.name))
Expand Down Expand Up @@ -1681,7 +1683,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat

def partitionColumnNotSpecifiedError(format: String, partitionColumn: String): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1128",
errorClass = "PARTITION_COLUMN_NOT_SPECIFIED",
messageParameters = Map(
"format" -> format,
"partitionColumn" -> partitionColumn))
Expand Down Expand Up @@ -1809,7 +1811,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat
def invalidPartitionColumnError(
partKey: String, targetPartitionSchema: StructType): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1145",
errorClass = "INVALID_PARTITION_COLUMN",
messageParameters = Map(
"partKey" -> partKey,
"partitionColumns" -> targetPartitionSchema.fields.map(_.name).mkString("[", ",", "]")))
Expand All @@ -1818,7 +1820,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat
def multiplePartitionColumnValuesSpecifiedError(
field: StructField, potentialSpecs: Map[String, String]): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1146",
errorClass = "MULTIPLE_PARTITION_COLUMN_VALUES_SPECIFIED",
messageParameters = Map(
"partColumn" -> field.name,
"values" -> potentialSpecs.mkString("[", ", ", "]")))
Expand Down Expand Up @@ -1883,8 +1885,8 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat

def partitionColumnNotFoundInSchemaError(col: String, schemaCatalog: String): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1155",
messageParameters = Map("col" -> col, "schemaCatalog" -> schemaCatalog))
errorClass = "PARTITION_COLUMN_NOT_FOUND_IN_SCHEMA",
messageParameters = Map("column" -> col, "schema" -> schemaCatalog))
}

def columnNotFoundInSchemaError(
Expand Down Expand Up @@ -1955,7 +1957,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat
specifiedPartCols: Seq[String],
existingPartCols: String): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1163",
errorClass = "MISMATCHED_TABLE_PARTITION_COLUMN",
messageParameters = Map(
"tableName" -> tableName,
"specifiedPartCols" -> specifiedPartCols.mkString(", "),
Expand Down Expand Up @@ -2716,7 +2718,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat
partitionColumnNames: Seq[String],
tableName: String): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1232",
errorClass = "INVALID_PARTITION_SPEC_KEYS",
messageParameters = Map(
"specKeys" -> specKeys,
"partitionColumnNames" -> partitionColumnNames.mkString(", "),
Expand Down
Loading