Skip to content

Commit

Permalink
[SPARK-47262][SQL] Assign names to error conditions for parquet conve…
Browse files Browse the repository at this point in the history
…rsions

### What changes were proposed in this pull request?
In the PR, I propose to rename the legacy error classes `_LEGACY_ERROR_TEMP_2238`, `_LEGACY_ERROR_TEMP_2239` and `_LEGACY_ERROR_TEMP_2240` to `PARQUET_CONVERSION_FAILURE.WITHOUT_DECIMAL_METADATA`, `PARQUET_CONVERSION_FAILURE.DECIMAL` and `PARQUET_CONVERSION_FAILURE`.

### Why are the changes needed?

Proper name improves user experience w/ Spark SQL.

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

No testing was needed.

### Was this patch authored or co-authored using generative AI tooling?

No

Closes #47802 from vladanvasi-db/vladanvasi-db/parquet-conversion-error-classes-fix.

Authored-by: Vladan Vasić <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
  • Loading branch information
vladanvasi-db authored and MaxGekk committed Aug 22, 2024
1 parent 98c7f51 commit 3e8cd99
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 22 deletions.
38 changes: 23 additions & 15 deletions common/utils/src/main/resources/error/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3580,6 +3580,29 @@
],
"sqlState" : "42805"
},
"PARQUET_CONVERSION_FAILURE" : {
"message" : [
"Unable to create a Parquet converter for the data type <dataType> whose Parquet type is <parquetType>."
],
"subClass" : {
"DECIMAL" : {
"message" : [
"Parquet DECIMAL type can only be backed by INT32, INT64, FIXED_LEN_BYTE_ARRAY, or BINARY."
]
},
"UNSUPPORTED" : {
"message" : [
"Please modify the conversion making sure it is supported."
]
},
"WITHOUT_DECIMAL_METADATA" : {
"message" : [
"Please read this column/field as Spark BINARY type."
]
}
},
"sqlState" : "42846"
},
"PARQUET_TYPE_ILLEGAL" : {
"message" : [
"Illegal Parquet type: <parquetType>."
Expand Down Expand Up @@ -7321,21 +7344,6 @@
"<className>.getParentLogger is not yet implemented."
]
},
"_LEGACY_ERROR_TEMP_2238" : {
"message" : [
"Unable to create Parquet converter for <typeName> whose Parquet type is <parquetType> without decimal metadata. Please read this column/field as Spark BINARY type."
]
},
"_LEGACY_ERROR_TEMP_2239" : {
"message" : [
"Unable to create Parquet converter for decimal type <t> whose Parquet type is <parquetType>. Parquet DECIMAL type can only be backed by INT32, INT64, FIXED_LEN_BYTE_ARRAY, or BINARY."
]
},
"_LEGACY_ERROR_TEMP_2240" : {
"message" : [
"Unable to create Parquet converter for data type <t> whose Parquet type is <parquetType>."
]
},
"_LEGACY_ERROR_TEMP_2241" : {
"message" : [
"Nonatomic partition table <tableName> can not add multiple partitions."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1943,27 +1943,27 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase with ExecutionE
def cannotCreateParquetConverterForTypeError(
t: DecimalType, parquetType: String): SparkRuntimeException = {
new SparkRuntimeException(
errorClass = "_LEGACY_ERROR_TEMP_2238",
errorClass = "PARQUET_CONVERSION_FAILURE.WITHOUT_DECIMAL_METADATA",
messageParameters = Map(
"typeName" -> t.typeName,
"dataType" -> toSQLType(t),
"parquetType" -> parquetType))
}

def cannotCreateParquetConverterForDecimalTypeError(
t: DecimalType, parquetType: String): SparkRuntimeException = {
new SparkRuntimeException(
errorClass = "_LEGACY_ERROR_TEMP_2239",
errorClass = "PARQUET_CONVERSION_FAILURE.DECIMAL",
messageParameters = Map(
"t" -> t.json,
"dataType" -> toSQLType(t),
"parquetType" -> parquetType))
}

def cannotCreateParquetConverterForDataTypeError(
t: DataType, parquetType: String): SparkRuntimeException = {
new SparkRuntimeException(
errorClass = "_LEGACY_ERROR_TEMP_2240",
errorClass = "PARQUET_CONVERSION_FAILURE.UNSUPPORTED",
messageParameters = Map(
"t" -> t.json,
"dataType" -> toSQLType(t),
"parquetType" -> parquetType))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ParquetTypeWideningSuite
exception.getCause
.isInstanceOf[org.apache.parquet.io.ParquetDecodingException] ||
exception.getCause.getMessage.contains(
"Unable to create Parquet converter for data type"))
"PARQUET_CONVERSION_FAILURE"))
} else {
checkAnswer(readParquetFiles(dir, toType), expected.select($"a".cast(toType)))
}
Expand Down

0 comments on commit 3e8cd99

Please sign in to comment.