Skip to content

Commit 564f1d2

Browse files
committed
fix: add missing aliases() method and improve regression test
- Add aliases() implementation to SparkDateDiff to properly expose 'datediff' alias - Update test to use checkSparkAnswerAndOperator for complete verification - Use fixed date instead of current_date() for reproducible testing - Addresses PR review comments
1 parent 1d0fab5 commit 564f1d2

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

native/spark-expr/src/datetime_funcs/date_diff.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ impl ScalarUDFImpl for SparkDateDiff {
6868
Ok(DataType::Int32)
6969
}
7070

71+
fn aliases(&self) -> &[String] {
72+
&self.aliases
73+
}
74+
7175
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
7276
let [end_date, start_date] = take_function_args(self.name(), args.args)?;
7377

spark/src/test/scala/org/apache/spark/sql/comet/ParquetDatetimeRebaseSuite.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ abstract class ParquetDatetimeRebaseSuite extends CometTestBase {
133133

134134
val readDf = spark.read.parquet(path.getAbsolutePath)
135135

136-
val result = readDf
137-
.selectExpr("datediff(current_date(), ts) as diff")
138-
.collect()
136+
// Use a fixed date for reproducible testing
137+
val resultDf = readDf
138+
.selectExpr("datediff(date '2024-01-10', ts) as diff")
139139

140-
// Just verify it executes correctly (no CometNativeException)
141-
assert(result.length == 2)
140+
// Verify result correctness and plan
141+
checkSparkAnswerAndOperator(resultDf)
142142
}
143143
}
144144
}

0 commit comments

Comments
 (0)