HyukjinKwon commented on a change in pull request #25242: [SPARK-28497][SQL]
Disallow upcasting complex data types to string type
URL: https://github.com/apache/spark/pull/25242#discussion_r307098867
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/encoders/EncoderResolutionSuite.scala
##########
@@ -196,6 +196,43 @@ class EncoderResolutionSuite extends PlanTest {
encoder.resolveAndBind(attrs)
}
+ test("SPARK-28497: complex type is not compatible with string encoder
schema") {
+ val encoder = ExpressionEncoder[String]
+
+ {
+ val attrs = Seq('a.struct('x.long))
+
assert(intercept[AnalysisException](encoder.resolveAndBind(attrs)).message ==
+ s"""
+ |Cannot up cast `a` from struct<x:bigint> to string.
+ |The type path of the target object is:
+ |- root class: "java.lang.String"
+ |You can either add an explicit cast to the input data or choose a
higher precision type
+ """.stripMargin.trim + " of the field in the target object")
+ }
+
+ {
+ val attrs = Seq('a.array(StringType))
+
assert(intercept[AnalysisException](encoder.resolveAndBind(attrs)).message ==
+ s"""
+ |Cannot up cast `a` from array<string> to string.
Review comment:
Oh, it was the same comment as
https://github.com/apache/spark/pull/25242#discussion_r307064357
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]