File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
main/scala/org/apache/comet/expressions
test/scala/org/apache/comet Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -71,8 +71,7 @@ object CometCast {
7171 Unsupported
7272 }
7373 case (_ : DecimalType , _ : DecimalType ) =>
74- // https://github.com/apache/datafusion-comet/issues/375
75- Incompatible ()
74+ Compatible ()
7675 case (DataTypes .StringType , _) =>
7776 canCastFromString(toType, timeZoneId, evalMode)
7877 case (_, DataTypes .StringType ) =>
Original file line number Diff line number Diff line change @@ -895,6 +895,18 @@ class CometCastSuite extends CometTestBase with AdaptiveSparkPlanHelper {
895895 }
896896 }
897897
898+ test(" cast between decimals with different precision and scale" ) {
899+ // cast between default Decimal(38, 18) to Decimal(9,1)
900+ val values = Seq (BigDecimal (" 12345.6789" ), BigDecimal (" 9876.5432" ), BigDecimal (" 123.4567" ))
901+ val df = withNulls(values).toDF(" a" )
902+ castTest(df, DataTypes .createDecimalType(7 , 2 ))
903+ }
904+
905+ test(" cast two between decimals with different precision and scale" ) {
906+ // cast between Decimal(10, 2) to Decimal(9,1)
907+ castTest(generateDecimalsPrecision10Scale2(), DataTypes .createDecimalType(9 , 1 ))
908+ }
909+
898910 private def generateFloats (): DataFrame = {
899911 withNulls(gen.generateFloats(dataSize)).toDF(" a" )
900912 }
You can’t perform that action at this time.
0 commit comments