@@ -262,6 +262,12 @@ class DateFunctionsValidateSuite extends FunctionsValidateSuite {
262262 }
263263 }
264264
265+ test(" timestamp_seconds" ) {
266+ runQueryAndCompare(" select timestamp_seconds(l_orderkey) from lineitem" ) {
267+ checkGlutenPlan[ProjectExecTransformer ]
268+ }
269+ }
270+
265271 test(" timestampadd" ) {
266272 withTempPath {
267273 path =>
@@ -341,6 +347,45 @@ class DateFunctionsValidateSuite extends FunctionsValidateSuite {
341347 }
342348 }
343349
350+ test(" last_day" ) {
351+ withTempPath {
352+ path =>
353+ Seq (
354+ java.sql.Date .valueOf(" 2022-02-15" ),
355+ java.sql.Date .valueOf(" 2022-03-20" ),
356+ java.sql.Date .valueOf(" 2020-02-10" )
357+ )
358+ .toDF(" dt" )
359+ .write
360+ .parquet(path.getCanonicalPath)
361+
362+ spark.read.parquet(path.getCanonicalPath).createOrReplaceTempView(" view" )
363+
364+ runQueryAndCompare(" SELECT last_day(dt) FROM view" ) {
365+ checkGlutenPlan[ProjectExecTransformer ]
366+ }
367+ }
368+ }
369+
370+ test(" next_day" ) {
371+ withTempPath {
372+ path =>
373+ Seq (
374+ java.sql.Date .valueOf(" 2022-02-15" ),
375+ java.sql.Date .valueOf(" 2022-03-20" )
376+ )
377+ .toDF(" dt" )
378+ .write
379+ .parquet(path.getCanonicalPath)
380+
381+ spark.read.parquet(path.getCanonicalPath).createOrReplaceTempView(" view" )
382+
383+ runQueryAndCompare(" SELECT next_day(dt, 'Monday') FROM view" ) {
384+ checkGlutenPlan[ProjectExecTransformer ]
385+ }
386+ }
387+ }
388+
344389 test(" trunc" ) {
345390 withTempPath {
346391 path =>
@@ -473,6 +518,40 @@ class DateFunctionsValidateSuite extends FunctionsValidateSuite {
473518 }
474519 }
475520
521+ test(" to_unix_timestamp" ) {
522+ withTempPath {
523+ path =>
524+ Seq (
525+ (Timestamp .valueOf(" 2016-04-08 13:10:15" ), " yyyy-MM-dd HH:mm:ss" ),
526+ (Timestamp .valueOf(" 2017-05-19 18:25:30" ), " yyyy-MM-dd HH:mm:ss" )
527+ ).toDF(" ts" , " fmt" ).write.parquet(path.getCanonicalPath)
528+
529+ spark.read
530+ .parquet(path.getCanonicalPath)
531+ .createOrReplaceTempView(" to_unix_timestamp_test" )
532+
533+ runQueryAndCompare(" SELECT to_unix_timestamp(ts, fmt) FROM to_unix_timestamp_test" ) {
534+ checkGlutenPlan[ProjectExecTransformer ]
535+ }
536+ }
537+ }
538+
539+ test(" from_unixtime" ) {
540+ withTempPath {
541+ path =>
542+ Seq (
543+ (1460118615L , " yyyy-MM-dd HH:mm:ss" ),
544+ (1495211130L , " MM/dd/yyyy HH:mm:ss" )
545+ ).toDF(" unix_time" , " fmt" ).write.parquet(path.getCanonicalPath)
546+
547+ spark.read.parquet(path.getCanonicalPath).createOrReplaceTempView(" from_unixtime_test" )
548+
549+ runQueryAndCompare(" SELECT from_unixtime(unix_time, fmt) FROM from_unixtime_test" ) {
550+ checkGlutenPlan[ProjectExecTransformer ]
551+ }
552+ }
553+ }
554+
476555 test(" months_between" ) {
477556 withTempPath {
478557 path =>
@@ -489,4 +568,5 @@ class DateFunctionsValidateSuite extends FunctionsValidateSuite {
489568 }
490569 }
491570 }
571+
492572}
0 commit comments