From 23e35d4f6cd75d3cc2a8054f8872fdf61c1a8bcc Mon Sep 17 00:00:00 2001 From: DB Tsai Date: Wed, 23 Jan 2019 17:43:43 -0800 Subject: [PATCH] [SPARK-26706][SQL][FOLLOWUP] Fix `illegalNumericPrecedence` for ByteType Removed automatically generated tests in ``` test("canSafeCast and mayTruncate must be consistent for numeric types") ``` since `canSafeCast` doesn't exit in 2.3 branch. We have enough test coverages in the explict casting tests. Authored-by: DB Tsai Signed-off-by: DB Tsai --- .../sql/catalyst/expressions/CastSuite.scala | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala index 777295c54cae6..079fc6b219282 100644 --- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala +++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala @@ -934,28 +934,4 @@ class CastSuite extends SparkFunSuite with ExpressionEvalHelper { assert(Cast.mayTruncate(DoubleType, ByteType)) assert(Cast.mayTruncate(DecimalType.IntDecimal, ByteType)) } - - test("canSafeCast and mayTruncate must be consistent for numeric types") { - import DataTypeTestUtils._ - - def isCastSafe(from: NumericType, to: NumericType): Boolean = (from, to) match { - case (_, dt: DecimalType) => dt.isWiderThan(from) - case (dt: DecimalType, _) => dt.isTighterThan(to) - case _ => numericPrecedence.indexOf(from) <= numericPrecedence.indexOf(to) - } - - numericTypes.foreach { from => - val (safeTargetTypes, unsafeTargetTypes) = numericTypes.partition(to => isCastSafe(from, to)) - - safeTargetTypes.foreach { to => - assert(Cast.canSafeCast(from, to), s"It should be possible to safely cast $from to $to") - assert(!Cast.mayTruncate(from, to), s"No truncation is expected when casting $from to $to") - } - - unsafeTargetTypes.foreach { to => - assert(!Cast.canSafeCast(from, to), s"It shouldn't be possible to safely cast $from to $to") - assert(Cast.mayTruncate(from, to), s"Truncation is expected when casting $from to $to") - } - } - } }