Skip to content

Commit

Permalink
Rename _Legacy_ERROR_TEMP_323[6-7] and correct pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
miland-db committed Mar 8, 2024
1 parent 4371d5d commit e1c4cb5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 36 deletions.
39 changes: 16 additions & 23 deletions common/utils/src/main/resources/error/error-classes.json
Original file line number Diff line number Diff line change
Expand Up @@ -7767,16 +7767,6 @@
"The numbers of zipped arrays and field names should be the same"
]
},
"_LEGACY_ERROR_TEMP_3236" : {
"message" : [
"Unsupported special character for delimiter: <str>"
]
},
"_LEGACY_ERROR_TEMP_3237" : {
"message" : [
"Delimiter cannot be more than one character: <str>"
]
},
"_LEGACY_ERROR_TEMP_3238" : {
"message" : [
"Failed to convert value <v> (class of <class>) in type <dt> to XML."
Expand Down Expand Up @@ -7824,33 +7814,36 @@
},
"INVALID_DELIMITER_VALUE" : {
"message" : [
"Invalid value for delimiter"
"Invalid value for delimiter."
],
"subClass" : {
"EMPTY_STRING": {
"message" : [
"Delimiter cannot be empty string"
"Delimiter cannot be empty string."
]
},
"SINGLE_BACKSLASH": {
"SINGLE_BACKSLASH" : {
"message" : [
"Single backslash is prohibited. It has special meaning as beginning of an escape sequence. To get the backslash character, pass a string with two backslashes as the delimiter."
]
}
}
},
"JSON_CONVERSION_ERROR" : {
"message" : [
"Invalid JSON conversion."
],
"subClass" : {
"UNSUPPORTED_VALUE_TYPE" : {
},
"UNSUPPORTED_SPECIAL_CHARACTER" : {
"message" : [
"Failed to convert value <value> (class of <valueClass>}) with the type of <dataType> to JSON."
"Unsupported special character for delimiter: <str>."
]
},
"DELIMITER_LONGER_THAN_EXPECTED" : {
"message" : [
"Delimiter cannot be more than one character: <str>."
]
}
}
},
"FAILED_ROW_TO_JSON" : {
"message" : [
"Failed to convert the row value <value> of the class <class> to the target SQL type <sqlType> in the JSON format."
]
},
"_LEGACY_ERROR_TEMP_3250" : {
"message" : [
"Failed to convert the JSON string '<other>' to a field."
Expand Down
9 changes: 5 additions & 4 deletions sql/api/src/main/scala/org/apache/spark/sql/Row.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.apache.spark.annotation.{Stable, Unstable}
import org.apache.spark.sql.catalyst.expressions.GenericRow
import org.apache.spark.sql.catalyst.util.{DateFormatter, SparkDateTimeUtils, TimestampFormatter, UDTUtils}
import org.apache.spark.sql.errors.DataTypeErrors
import org.apache.spark.sql.errors.DataTypeErrors.{toSQLType, toSQLValue}
import org.apache.spark.sql.internal.SqlApiConf
import org.apache.spark.sql.types._
import org.apache.spark.unsafe.types.CalendarInterval
Expand Down Expand Up @@ -611,11 +612,11 @@ trait Row extends Serializable {
case (v: Any, udt: UserDefinedType[Any @unchecked]) =>
toJson(UDTUtils.toRow(v, udt), udt.sqlType)
case _ => throw new SparkIllegalArgumentException(
errorClass = "JSON_CONVERSION_ERROR.UNSUPPORTED_VALUE_TYPE",
errorClass = "FAILED_ROW_TO_JSON",
messageParameters = Map(
"value" -> value.toString,
"valueClass" -> value.getClass.toString,
"dataType" -> dataType.toString)
"value" -> toSQLValue(value.toString),
"class" -> value.getClass.toString,
"sqlType" -> toSQLType(dataType.toString))
)
}
toJson(this, schema)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ object CSVExprUtils {
case _ if str == "\u0000" => '\u0000'
case Seq('\\', _) =>
throw new SparkIllegalArgumentException(
errorClass = "_LEGACY_ERROR_TEMP_3236", messageParameters = Map("str" -> str))
errorClass =
"INVALID_DELIMITER_VALUE.UNSUPPORTED_SPECIAL_CHARACTER",
messageParameters = Map("str" -> str))
case _ =>
throw new SparkIllegalArgumentException(
errorClass = "_LEGACY_ERROR_TEMP_3237", messageParameters = Map("str" -> str))
errorClass =
"INVALID_DELIMITER_VALUE.DELIMITER_LONGER_THAN_EXPECTED",
messageParameters = Map("str" -> str))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.json4s.JsonAST.{JArray, JBool, JDecimal, JDouble, JLong, JNull, JObje
import org.apache.spark.{SparkFunSuite, SparkIllegalArgumentException}
import org.apache.spark.sql.catalyst.encoders.{ExamplePoint, ExamplePointUDT}
import org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema
import org.apache.spark.sql.errors.DataTypeErrors.{toSQLType, toSQLValue}
import org.apache.spark.sql.types._

/**
Expand Down Expand Up @@ -135,10 +136,12 @@ class RowJsonSuite extends SparkFunSuite {
new StructType().add("a", ObjectType(classOf[(Int, Int)])))
row.jsonValue
},
errorClass = "JSON_CONVERSION_ERROR.UNSUPPORTED_VALUE_TYPE",
errorClass = "FAILED_ROW_TO_JSON",
parameters = Map(
"value" -> "(1,2)",
"valueClass" -> "class scala.Tuple2$mcII$sp",
"dataType" -> "ObjectType(class scala.Tuple2)"))
"value" -> toSQLValue("(1,2)"),
"class" -> "class scala.Tuple2$mcII$sp",
"sqlType" -> toSQLType("ObjectType(class scala.Tuple2)")
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CSVExprUtilsSuite extends SparkFunSuite {
exception = intercept[SparkIllegalArgumentException]{
CSVExprUtils.toChar("ab")
},
errorClass = "_LEGACY_ERROR_TEMP_3237",
errorClass = "INVALID_DELIMITER_VALUE.DELIMITER_LONGER_THAN_EXPECTED",
parameters = Map("str" -> "ab"))
}

Expand All @@ -47,7 +47,7 @@ class CSVExprUtilsSuite extends SparkFunSuite {
exception = intercept[SparkIllegalArgumentException]{
CSVExprUtils.toChar("""\1""")
},
errorClass = "_LEGACY_ERROR_TEMP_3236",
errorClass = "INVALID_DELIMITER_VALUE.UNSUPPORTED_SPECIAL_CHARACTER",
parameters = Map("str" -> """\1"""))
}

Expand Down Expand Up @@ -76,7 +76,7 @@ class CSVExprUtilsSuite extends SparkFunSuite {
// backslash, then tab
("""\\t""", Some("""\t"""), None),
// invalid special character (dot)
("""\.""", None, Some("_LEGACY_ERROR_TEMP_3236")),
("""\.""", None, Some("INVALID_DELIMITER_VALUE.UNSUPPORTED_SPECIAL_CHARACTER")),
// backslash, then dot
("""\\.""", Some("""\."""), None),
// nothing special, just straight conversion
Expand Down

0 comments on commit e1c4cb5

Please sign in to comment.