Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
[SPARK-50246][SQL] Assign appropriate error condition for _LEGACY_ERR…
…OR_TEMP_2167: MALFORMED_RECORD_IN_SCHEMA_INFERENCE
  • Loading branch information
itholic committed Nov 6, 2024
commit 4607af16659208c09af08cd9859b98e8a8ab350d
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 @@ -3439,6 +3439,12 @@
},
"sqlState" : "22023"
},
"MALFORMED_RECORD_IN_SCHEMA_INFERENCE" : {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error condition is pretty much related to JSON. Let's reflect this in its name.

Also the record might be a correct JSON record but has unexpected type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.
Just applied the comments, thanks!

"message" : [
"Malformed records are detected in schema inference. Parse Mode: <failFastMode>. Reasons: Failed to infer a common schema. Struct types are expected, but <dataType> was found."
],
"sqlState" : "22023"
},
"MALFORMED_VARIANT" : {
"message" : [
"Variant binary is malformed. Please check the data source is valid."
Expand Down Expand Up @@ -7284,11 +7290,6 @@
"Malformed JSON."
]
},
"_LEGACY_ERROR_TEMP_2167" : {
"message" : [
"Malformed records are detected in schema inference. Parse Mode: <failFastMode>. Reasons: Failed to infer a common schema. Struct types are expected, but `<dataType>` was found."
]
},
"_LEGACY_ERROR_TEMP_2168" : {
"message" : [
"Decorrelate inner query through <plan> is not supported."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1437,10 +1437,10 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase with ExecutionE

def malformedRecordsDetectedInSchemaInferenceError(dataType: DataType): Throwable = {
new SparkException(
errorClass = "_LEGACY_ERROR_TEMP_2167",
errorClass = "MALFORMED_RECORD_IN_SCHEMA_INFERENCE",
messageParameters = Map(
"failFastMode" -> FailFastMode.name,
"dataType" -> dataType.catalogString),
"dataType" -> toSQLType(dataType)),
cause = null)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2078,8 +2078,8 @@ abstract class JsonSuite
.option("mode", "FAILFAST")
.json(path)
},
condition = "_LEGACY_ERROR_TEMP_2167",
parameters = Map("failFastMode" -> "FAILFAST", "dataType" -> "string|bigint"))
condition = "MALFORMED_RECORD_IN_SCHEMA_INFERENCE",
parameters = Map("failFastMode" -> "FAILFAST", "dataType" -> "\"STRING\"|\"BIGINT\""))

val ex = intercept[SparkException] {
spark.read
Expand Down