Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down Expand Up @@ -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 =>
Expand Down Expand Up @@ -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 =>
Expand All @@ -489,4 +568,5 @@ class DateFunctionsValidateSuite extends FunctionsValidateSuite {
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
Loading