mrk-andreev commented on code in PR #47522:
URL: https://github.com/apache/spark/pull/47522#discussion_r1741258282
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ObjectExpressionsSuite.scala:
##########
@@ -556,6 +556,43 @@ class ObjectExpressionsSuite extends SparkFunSuite with
ExpressionEvalHelper {
"java.lang.Integer is not a valid external type for schema of double")
}
+ test("SPARK-49044 ValidateExternalType should return child in error") {
+ val inputObject = BoundReference(0, ObjectType(classOf[Row]), nullable =
true)
+ Seq(
+ (true, BooleanType),
+ (2.toByte, ByteType),
+ (5.toShort, ShortType),
+ (23, IntegerType),
+ (61L, LongType),
+ (1.0f, FloatType),
+ (10.0, DoubleType),
+ ("abcd".getBytes, BinaryType),
+ ("abcd", StringType),
+ (BigDecimal.valueOf(10), DecimalType.IntDecimal),
+ (IntervalUtils.stringToInterval(UTF8String.fromString("interval 3 day")),
+ CalendarIntervalType),
+ (java.math.BigDecimal.valueOf(10), DecimalType.BigIntDecimal),
+ (Array(3, 2, 1), ArrayType(IntegerType))
+ ).foreach { case (input, dt) =>
+ val enc = RowEncoder.encoderForDataType(dt, lenient = false)
+ val validateType = ValidateExternalType(
+ GetExternalRowField(inputObject, index = 0, fieldName = "c0"),
+ dt,
+ EncoderUtils.lenientExternalDataTypeFor(enc))
+ checkObjectExprEvaluation(validateType, input,
InternalRow.fromSeq(Seq(Row(input))))
+ }
+
+ checkExceptionInExpression[SparkRuntimeException](
+ ValidateExternalType(
Review Comment:
Summary.
* Integration test placed here
`sql/core/src/test/scala/org/apache/spark/sql/catalyst/expressions/ValidateExternalTypeSuite.scala`
(checkError + spark.createDataFrame)
* Unit test placed here
`sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ObjectExpressionsSuite.scala`
Also because we changed error message some other tests like
`sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/encoders/RowEncoderSuite.scala`
was also changed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]