File tree Expand file tree Collapse file tree
spark/src/test/scala/org/apache/spark/sql/comet Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -116,6 +116,33 @@ abstract class ParquetDatetimeRebaseSuite extends CometTestBase {
116116 }
117117 }
118118
119+ test(" COMET-XXXX: datediff works with dictionary-encoded timestamp columns" ) {
120+ withTempPath { path =>
121+ withSQLConf(
122+ CometConf .COMET_NATIVE_SCAN_IMPL .key -> CometConf .SCAN_NATIVE_COMET ,
123+ CometConf .COMET_ENABLED .key -> " true" ,
124+ " spark.sql.parquet.enableDictionary" -> " true" ) {
125+ val df = spark
126+ .createDataFrame(
127+ Seq (
128+ (" a" , java.sql.Timestamp .valueOf(" 2024-01-02 10:00:00" )),
129+ (" b" , java.sql.Timestamp .valueOf(" 2024-01-03 11:00:00" ))))
130+ .toDF(" id" , " ts" )
131+
132+ df.write.mode(" overwrite" ).parquet(path.getAbsolutePath)
133+
134+ val readDf = spark.read.parquet(path.getAbsolutePath)
135+
136+ val result = readDf
137+ .selectExpr(" datediff(current_date(), ts) as diff" )
138+ .collect()
139+
140+ // Just verify it executes correctly (no CometNativeException)
141+ assert(result.length == 2 )
142+ }
143+ }
144+ }
145+
119146 private def checkSparkNoRebaseAnswer (df : => DataFrame ): Unit = {
120147 var expected : Array [Row ] = Array .empty
121148
You can’t perform that action at this time.
0 commit comments