@@ -719,9 +719,17 @@ class CometCastSuite extends CometTestBase with AdaptiveSparkPlanHelper {
719719
720720 test(" cast StringType to DecimalType(2,2)" ) {
721721 withSQLConf(CometConf .getExprAllowIncompatConfigKey(classOf [Cast ]) -> " true" ) {
722- // TODO fix for Spark 4.0.0
723- assume(! isSpark40Plus)
724- val values = gen.generateStrings(dataSize, numericPattern, 12 ).toDF(" a" )
722+ println(" testing with simple input" )
723+ val values = Seq (" 3" ).toDF(" a" )
724+ Seq (true , false ).foreach(ansiEnabled =>
725+ castTest(values, DataTypes .createDecimalType(2 , 2 ), testAnsi = ansiEnabled))
726+ }
727+ }
728+
729+ test(" cast StringType to DecimalType(2,2) check if right exception is being thrown" ) {
730+ withSQLConf(CometConf .getExprAllowIncompatConfigKey(classOf [Cast ]) -> " true" ) {
731+ println(" testing with simple input" )
732+ val values = Seq (" 3" ).toDF(" a" )
725733 Seq (true , false ).foreach(ansiEnabled =>
726734 castTest(values, DataTypes .createDecimalType(2 , 2 ), testAnsi = ansiEnabled))
727735 }
@@ -731,7 +739,17 @@ class CometCastSuite extends CometTestBase with AdaptiveSparkPlanHelper {
731739 withSQLConf(CometConf .getExprAllowIncompatConfigKey(classOf [Cast ]) -> " true" ) {
732740 // TODO fix for Spark 4.0.0
733741 assume(! isSpark40Plus)
734- val values = gen.generateStrings(dataSize, numericPattern, 38 ).toDF(" a" )
742+ val values = Seq (" 0e31" ).toDF(" a" )
743+ Seq (true , false ).foreach(ansiEnabled =>
744+ castTest(values, DataTypes .createDecimalType(38 , 10 ), testAnsi = ansiEnabled))
745+ }
746+ }
747+
748+ test(" cast StringType to DecimalType(38,10) high precision - 0 mantissa" ) {
749+ withSQLConf(CometConf .getExprAllowIncompatConfigKey(classOf [Cast ]) -> " true" ) {
750+ // TODO fix for Spark 4.0.0
751+ assume(! isSpark40Plus)
752+ val values = Seq (" 0e31" ).toDF(" a" )
735753 Seq (true , false ).foreach(ansiEnabled =>
736754 castTest(values, DataTypes .createDecimalType(38 , 10 ), testAnsi = ansiEnabled))
737755 }
0 commit comments