This is an automated email from the ASF dual-hosted git repository.
yuanzhou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gluten.git
The following commit(s) were added to refs/heads/main by this push:
new 3dd279f7dc [GLUTEN-11622][VL] Adds missing validation tests for
timestamp related functions (#11890)
3dd279f7dc is described below
commit 3dd279f7dcfcccc24cf5c2629299d912f0f2dc4d
Author: Mariam AlMesfer <[email protected]>
AuthorDate: Mon Apr 13 12:56:17 2026 +0300
[GLUTEN-11622][VL] Adds missing validation tests for timestamp related
functions (#11890)
Add tests for some missing timestamp functions in the Velox backend.
New tests include:
Minute
Second
SecondsToTimestamp
ToUnixTimestamp
FromUnixTime
LastDay
NextDay
Related issue: #11622
Co-authored-by: Mariam-Almesfer <[email protected]>
---
.../functions/DateFunctionsValidateSuite.scala | 80 ++++++++++++++++++++++
.../functions/ScalarFunctionsValidateSuite.scala | 18 +++++
2 files changed, 98 insertions(+)
diff --git
a/backends-velox/src/test/scala/org/apache/gluten/functions/DateFunctionsValidateSuite.scala
b/backends-velox/src/test/scala/org/apache/gluten/functions/DateFunctionsValidateSuite.scala
index d120842fd2..70d9bffdce 100644
---
a/backends-velox/src/test/scala/org/apache/gluten/functions/DateFunctionsValidateSuite.scala
+++
b/backends-velox/src/test/scala/org/apache/gluten/functions/DateFunctionsValidateSuite.scala
@@ -262,6 +262,12 @@ class DateFunctionsValidateSuite extends
FunctionsValidateSuite {
}
}
+ test("timestamp_seconds") {
+ runQueryAndCompare("select timestamp_seconds(l_orderkey) from lineitem") {
+ checkGlutenPlan[ProjectExecTransformer]
+ }
+ }
+
test("timestampadd") {
withTempPath {
path =>
@@ -341,6 +347,45 @@ class DateFunctionsValidateSuite extends
FunctionsValidateSuite {
}
}
+ test("last_day") {
+ withTempPath {
+ path =>
+ Seq(
+ java.sql.Date.valueOf("2022-02-15"),
+ java.sql.Date.valueOf("2022-03-20"),
+ java.sql.Date.valueOf("2020-02-10")
+ )
+ .toDF("dt")
+ .write
+ .parquet(path.getCanonicalPath)
+
+
spark.read.parquet(path.getCanonicalPath).createOrReplaceTempView("view")
+
+ runQueryAndCompare("SELECT last_day(dt) FROM view") {
+ checkGlutenPlan[ProjectExecTransformer]
+ }
+ }
+ }
+
+ test("next_day") {
+ withTempPath {
+ path =>
+ Seq(
+ java.sql.Date.valueOf("2022-02-15"),
+ java.sql.Date.valueOf("2022-03-20")
+ )
+ .toDF("dt")
+ .write
+ .parquet(path.getCanonicalPath)
+
+
spark.read.parquet(path.getCanonicalPath).createOrReplaceTempView("view")
+
+ runQueryAndCompare("SELECT next_day(dt, 'Monday') FROM view") {
+ checkGlutenPlan[ProjectExecTransformer]
+ }
+ }
+ }
+
test("trunc") {
withTempPath {
path =>
@@ -473,6 +518,40 @@ class DateFunctionsValidateSuite extends
FunctionsValidateSuite {
}
}
+ test("to_unix_timestamp") {
+ withTempPath {
+ path =>
+ Seq(
+ (Timestamp.valueOf("2016-04-08 13:10:15"), "yyyy-MM-dd HH:mm:ss"),
+ (Timestamp.valueOf("2017-05-19 18:25:30"), "yyyy-MM-dd HH:mm:ss")
+ ).toDF("ts", "fmt").write.parquet(path.getCanonicalPath)
+
+ spark.read
+ .parquet(path.getCanonicalPath)
+ .createOrReplaceTempView("to_unix_timestamp_test")
+
+ runQueryAndCompare("SELECT to_unix_timestamp(ts, fmt) FROM
to_unix_timestamp_test") {
+ checkGlutenPlan[ProjectExecTransformer]
+ }
+ }
+ }
+
+ test("from_unixtime") {
+ withTempPath {
+ path =>
+ Seq(
+ (1460118615L, "yyyy-MM-dd HH:mm:ss"),
+ (1495211130L, "MM/dd/yyyy HH:mm:ss")
+ ).toDF("unix_time", "fmt").write.parquet(path.getCanonicalPath)
+
+
spark.read.parquet(path.getCanonicalPath).createOrReplaceTempView("from_unixtime_test")
+
+ runQueryAndCompare("SELECT from_unixtime(unix_time, fmt) FROM
from_unixtime_test") {
+ checkGlutenPlan[ProjectExecTransformer]
+ }
+ }
+ }
+
test("months_between") {
withTempPath {
path =>
@@ -489,4 +568,5 @@ class DateFunctionsValidateSuite extends
FunctionsValidateSuite {
}
}
}
+
}
diff --git
a/backends-velox/src/test/scala/org/apache/gluten/functions/ScalarFunctionsValidateSuite.scala
b/backends-velox/src/test/scala/org/apache/gluten/functions/ScalarFunctionsValidateSuite.scala
index 6a0516ce66..4deff767bf 100644
---
a/backends-velox/src/test/scala/org/apache/gluten/functions/ScalarFunctionsValidateSuite.scala
+++
b/backends-velox/src/test/scala/org/apache/gluten/functions/ScalarFunctionsValidateSuite.scala
@@ -226,6 +226,24 @@ abstract class ScalarFunctionsValidateSuite extends
FunctionsValidateSuite {
sql("INSERT INTO t1 VALUES(1, NOW())")
runQueryAndCompare("SELECT c1, HOUR(c2) FROM t1 LIMIT 1")(df =>
checkFallbackOperators(df, 0))
}
+
+ test("MINUTE") {
+ withTable("t1") {
+ sql("create table t1 (c1 int, c2 timestamp) USING PARQUET")
+ sql("INSERT INTO t1 VALUES(1, NOW())")
+ runQueryAndCompare("SELECT c1, MINUTE(c2) FROM t1 LIMIT 1")(
+ df => checkFallbackOperators(df, 0))
+ }
+ }
+
+ test("SECOND") {
+ withTable("t1") {
+ sql("create table t1 (c1 int, c2 timestamp) USING PARQUET")
+ sql("INSERT INTO t1 VALUES(1, NOW())")
+ runQueryAndCompare("SELECT c1, SECOND(c2) FROM t1 LIMIT 1")(
+ df => checkFallbackOperators(df, 0))
+ }
+ }
}
test("map extract - getmapvalue") {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]