@@ -24,7 +24,7 @@ import java.util
24
24
import org .apache .hadoop .fs .Path
25
25
import org .apache .spark .sql .{CometTestBase , DataFrame , Row }
26
26
import org .apache .spark .sql .execution .adaptive .AdaptiveSparkPlanHelper
27
- import org .apache .spark .sql .functions .expr
27
+ import org .apache .spark .sql .functions .{ expr , lit }
28
28
import org .apache .spark .sql .internal .SQLConf
29
29
import org .apache .spark .sql .internal .SQLConf .SESSION_LOCAL_TIMEZONE
30
30
import org .apache .spark .sql .types .{Decimal , DecimalType , StructType }
@@ -47,6 +47,29 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper {
47
47
}
48
48
}
49
49
50
+ test(" decimals divide by zero" ) {
51
+ // TODO: enable Spark 3.2 & 3.3 tests after supporting decimal divide operation
52
+ assume(isSpark34Plus)
53
+
54
+ Seq (true , false ).foreach { dictionary =>
55
+ withSQLConf(
56
+ SQLConf .PARQUET_WRITE_LEGACY_FORMAT .key -> " false" ,
57
+ " parquet.enable.dictionary" -> dictionary.toString) {
58
+ withTempPath { dir =>
59
+ val data = makeDecimalRDD(10 , DecimalType (18 , 10 ), dictionary)
60
+ data.write.parquet(dir.getCanonicalPath)
61
+ readParquetFile(dir.getCanonicalPath) { df =>
62
+ {
63
+ val decimalLiteral = Decimal (0.00 )
64
+ val cometDf = df.select($" dec" / decimalLiteral, $" dec" % decimalLiteral)
65
+ checkSparkAnswerAndOperator(cometDf)
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
72
+
50
73
test(" bitwise shift with different left/right types" ) {
51
74
Seq (false , true ).foreach { dictionary =>
52
75
withSQLConf(" parquet.enable.dictionary" -> dictionary.toString) {
0 commit comments