Skip to content

Commit

Permalink
[SPARK-45213][SQL] Assign name to the error _LEGACY_ERROR_TEMP_2151
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?
Assign the name `EXPRESSION_DECODING_FAILED` to the legacy error class `_LEGACY_ERROR_TEMP_2151`.

### Why are the changes needed?
To assign proper name as a part of activity in SPARK-37935.

### Does this PR introduce _any_ user-facing change?
Yes, the error message will include the error class name

### How was this patch tested?
An existing unit test to produce the error from user code.

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

Closes #43029 from dengziming/SPARK-45213.

Authored-by: dengziming <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
  • Loading branch information
dengziming authored and MaxGekk committed Oct 10, 2023
1 parent 397bbb6 commit 6373f19
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
11 changes: 5 additions & 6 deletions common/utils/src/main/resources/error/error-classes.json
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,11 @@
}
}
},
"EXPRESSION_DECODING_FAILED" : {
"message" : [
"Failed to decode a row to a value of the expressions: <expressions>."
]
},
"EXPRESSION_TYPE_IS_NOT_ORDERABLE" : {
"message" : [
"Column expression <expr> cannot be sorted because its type <exprType> is not orderable."
Expand Down Expand Up @@ -5524,12 +5529,6 @@
"Due to Scala's limited support of tuple, tuple with more than 22 elements are not supported."
]
},
"_LEGACY_ERROR_TEMP_2151" : {
"message" : [
"Error while decoding: <e>",
"<expressions>."
]
},
"_LEGACY_ERROR_TEMP_2152" : {
"message" : [
"Error while encoding: <e>",
Expand Down
6 changes: 6 additions & 0 deletions docs/sql-error-conditions.md
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,12 @@ The table `<tableName>` does not support `<operation>`.

For more details see [EXPECT_VIEW_NOT_TABLE](sql-error-conditions-expect-view-not-table-error-class.html)

### EXPRESSION_DECODING_FAILED

SQLSTATE: none assigned

Failed to decode a row to a value of the expressions: `<expressions>`.

### EXPRESSION_TYPE_IS_NOT_ORDERABLE

SQLSTATE: none assigned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1342,9 +1342,8 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase with ExecutionE

def expressionDecodingError(e: Exception, expressions: Seq[Expression]): SparkRuntimeException = {
new SparkRuntimeException(
errorClass = "_LEGACY_ERROR_TEMP_2151",
errorClass = "EXPRESSION_DECODING_FAILED",
messageParameters = Map(
"e" -> e.toString(),
"expressions" -> expressions.map(
_.simpleString(SQLConf.get.maxToStringFields)).mkString("\n")),
cause = e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class EncoderResolutionSuite extends PlanTest {
val e = intercept[RuntimeException] {
fromRow(InternalRow(new GenericArrayData(Array(1, null))))
}
assert(e.getMessage.contains("Null value appeared in non-nullable field"))
assert(e.getCause.getMessage.contains("Null value appeared in non-nullable field"))
}

test("the real number of fields doesn't match encoder schema: tuple encoder") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ class DatasetSuite extends QueryTest

val message = intercept[RuntimeException] {
buildDataset(Row(Row("hello", null))).collect()
}.getMessage
}.getCause.getMessage

assert(message.contains("Null value appeared in non-nullable field"))
}
Expand Down Expand Up @@ -2592,9 +2592,8 @@ class DatasetSuite extends QueryTest
// Expression decoding error
checkError(
exception = exception,
errorClass = "_LEGACY_ERROR_TEMP_2151",
errorClass = "EXPRESSION_DECODING_FAILED",
parameters = Map(
"e" -> exception.getCause.toString(),
"expressions" -> expressions.map(
_.simpleString(SQLConf.get.maxToStringFields)).mkString("\n"))
)
Expand Down

0 comments on commit 6373f19

Please sign in to comment.