Github user viirya commented on a diff in the pull request:
https://github.com/apache/spark/pull/10410#discussion_r48132865
--- Diff:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala
---
@@ -790,4 +820,25 @@ class CastSuite extends SparkFunSuite with
ExpressionEvalHelper {
checkEvaluation(cast("abc", BooleanType), null)
checkEvaluation(cast("", BooleanType), null)
}
+
+ test("cast between UserDefinedTypes") {
+ assert(Cast.canCast(new ExampleUDT, new ExampleUDT) == true)
+ assert(Cast.canCast(new ExampleUDT, new Example2UDT) == false)
+
+ val udt = new ExampleClass
+
+ val castExpression = Cast(Literal.create(udt, new ExampleUDT), new
ExampleUDT)
+ checkEvaluationWithoutCodegen(castExpression, udt)
+ val castExpression2 = Cast(Literal.create(0.0, new ExampleUDT), new
ExampleUDT)
+ checkEvaluationWithGeneratedMutableProjection(castExpression2, 0.0)
--- End diff --
For codgen case, the internal data for ExampleUDT here is double.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]