File tree Expand file tree Collapse file tree
backends-velox/src/test/scala/org/apache/gluten/functions
gluten-substrait/src/main/scala/org/apache/gluten/extension/columnar/validator Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -599,12 +599,15 @@ class DateFunctionsValidateSuite extends FunctionsValidateSuite {
599599 checkGlutenPlan[BatchScanExecTransformer ]
600600 }
601601
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)
602+ // cast(timestamp_ntz as string) runs natively.
603+ runQueryAndCompare(" select cast(ts as string) from view" ) {
604+ checkGlutenPlan[ProjectExecTransformer ]
605+ }
606+
607+ // cast(string as timestamp_ntz) runs natively.
608+ spark.createDataset(inputs).toDF(" str" ).createOrReplaceTempView(" str_view" )
609+ runQueryAndCompare(" select cast(str as timestamp_ntz) from str_view" ) {
610+ checkGlutenPlan[ProjectExecTransformer ]
608611 }
609612 }
610613 }
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ RUN_SETUP_SCRIPT=ON
2525ENABLE_ENHANCED_FEATURES=OFF
2626
2727# Developer use only for testing Velox PR.
28- UPSTREAM_VELOX_PR_ID=" "
28+ UPSTREAM_VELOX_PR_ID=" 17498 "
2929
3030OS=` uname -s`
3131
Original file line number Diff line number Diff line change @@ -262,9 +262,12 @@ object Validators {
262262 case p if HiveTableScanExecTransformer .isHiveTableScan(p) => true
263263 case _ => false
264264 }
265- val hasNTZ = plan.output.exists(a => containsNTZ(a.dataType)) ||
266- plan.children.exists(_.output.exists(a => containsNTZ(a.dataType)))
267- if (isScan || ! hasNTZ) {
265+ // Allow nodes that either consume NTZ (e.g. hour(timestamp_ntz) -> int)
266+ // or produce NTZ from non-NTZ input (e.g. cast(string as timestamp_ntz)).
267+ // Only fall back when NTZ propagates unchanged through both input and output.
268+ val inputHasNTZ = plan.children.exists(_.output.exists(a => containsNTZ(a.dataType)))
269+ val outputHasNTZ = plan.output.exists(a => containsNTZ(a.dataType))
270+ if (isScan || ! (inputHasNTZ && outputHasNTZ)) {
268271 return pass()
269272 }
270273 }
You can’t perform that action at this time.
0 commit comments