mrk-andreev commented on code in PR #47522:
URL: https://github.com/apache/spark/pull/47522#discussion_r1740164266


##########
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:
   Yes, look like internal because that look like internals:
   
   ```
   case class ValidateExternalType might be called from:
       | org.apache.spark.sql.catalyst.SerializerBuildHelper::createSerializer  
might be called from:
           |  org.apache.spark.sql.catalyst.encoders.ExpressionEncoder::apply
   ```
   
   in "user like" level we may face this exception in 
`TextSocketContinuousStream` that actually tutorials only code. 



-- 
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]

Reply via email to