|
16 | 16 | */ |
17 | 17 | package org.apache.gluten.functions |
18 | 18 |
|
19 | | -import org.apache.gluten.execution.ProjectExecTransformer |
| 19 | +import org.apache.gluten.execution.{BatchScanExecTransformer, ProjectExecTransformer} |
20 | 20 |
|
21 | 21 | import org.apache.spark.sql.execution.ProjectExec |
22 | 22 | import org.apache.spark.sql.types.Decimal |
@@ -569,4 +569,43 @@ class DateFunctionsValidateSuite extends FunctionsValidateSuite { |
569 | 569 | } |
570 | 570 | } |
571 | 571 |
|
| 572 | + testWithMinSparkVersion("read as timestamp_ntz", "3.4") { |
| 573 | + val inputs: Seq[String] = Seq( |
| 574 | + "1970-01-01", |
| 575 | + "1970-01-01 00:00:00-02:00", |
| 576 | + "1970-01-01 00:00:00 +02:00", |
| 577 | + "2000-01-01", |
| 578 | + "1970-01-01 00:00:00", |
| 579 | + "2000-01-01 12:21:56", |
| 580 | + "2015-03-18T12:03:17Z", |
| 581 | + "2015-03-18 12:03:17", |
| 582 | + "2015-03-18T12:03:17", |
| 583 | + "2015-03-18 12:03:17.123", |
| 584 | + "2015-03-18T12:03:17.123", |
| 585 | + "2015-03-18T12:03:17.456", |
| 586 | + "2015-03-18 12:03:17.456" |
| 587 | + ) |
| 588 | + |
| 589 | + withTempPath { |
| 590 | + dir => |
| 591 | + val path = dir.getAbsolutePath |
| 592 | + val inputDF = spark.createDataset(inputs).toDF("input") |
| 593 | + val df = inputDF.selectExpr("cast(input as timestamp_ntz) as ts") |
| 594 | + df.coalesce(1).write.mode("overwrite").parquet(path) |
| 595 | + val readDf = spark.read.parquet(path) |
| 596 | + readDf.createOrReplaceTempView("view") |
| 597 | + |
| 598 | + runQueryAndCompare("select * from view") { |
| 599 | + checkGlutenPlan[BatchScanExecTransformer] |
| 600 | + } |
| 601 | + |
| 602 | + // Ensures the fallback of unsupported function works. |
| 603 | + runQueryAndCompare("select hour(ts) from view") { |
| 604 | + df => |
| 605 | + assert(collect(df.queryExecution.executedPlan) { |
| 606 | + case p if p.isInstanceOf[ProjectExec] => p |
| 607 | + }.nonEmpty) |
| 608 | + } |
| 609 | + } |
| 610 | + } |
572 | 611 | } |
0 commit comments