cloud-fan commented on a change in pull request #31859:
URL: https://github.com/apache/spark/pull/31859#discussion_r596926825



##########
File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnsiTypeCoercionSuite.scala
##########
@@ -377,10 +368,26 @@ class AnsiTypeCoercionSuite extends AnalysisTest {
       ArrayType(StringType, true),
       TypeCollection(ArrayType(StringType), StringType),
       ArrayType(StringType, true))
+
+    // When there are multiple convertible types in the `TypeCollection`, use 
the closet convertible
+    // data type among convertible types.
+    shouldCast(IntegerType, TypeCollection(BinaryType, FloatType, LongType), 
LongType)
+    shouldCast(IntegerType, TypeCollection(BinaryType, LongType, NumericType), 
IntegerType)
+    // If the result is Float type and Double type is also among the 
convertible target types,
+    // use Double Type instead of Float type.
+    shouldCast(LongType, TypeCollection(FloatType, DoubleType, StringType), 
DoubleType)
   }
 
   test("ineligible implicit type cast - TypeCollection") {
+    shouldNotCast(IntegerType, TypeCollection(StringType, BinaryType))
+    shouldNotCast(IntegerType, TypeCollection(BinaryType, StringType))
     shouldNotCast(IntegerType, TypeCollection(DateType, TimestampType))
+    shouldNotCast(IntegerType, TypeCollection(DecimalType(10, 2), StringType))
+    shouldNotCastStringInput(TypeCollection(NumericType, BinaryType))
+    // When there are multiple convertible types in the `TypeCollection` and 
there is no closest
+    // convertible data type among the convertible types.
+    shouldNotCastStringLiteral(TypeCollection(NumericType, BinaryType))

Review comment:
       This duplicates the previous case.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to