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 d120842fd292..70d9bffdceaf 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 6a0516ce666f..4deff767bfa3 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") {