Skip to content
Draft
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 @@ -599,12 +599,15 @@ class DateFunctionsValidateSuite extends FunctionsValidateSuite {
checkGlutenPlan[BatchScanExecTransformer]
}

// Ensures the fallback of unsupported function works.
runQueryAndCompare("select hour(ts) from view") {
df =>
assert(collect(df.queryExecution.executedPlan) {
case p if p.isInstanceOf[ProjectExec] => p
}.nonEmpty)
// cast(timestamp_ntz as string) runs natively.
runQueryAndCompare("select cast(ts as string) from view") {
checkGlutenPlan[ProjectExecTransformer]
}

// cast(string as timestamp_ntz) runs natively.
spark.createDataset(inputs).toDF("str").createOrReplaceTempView("str_view")
runQueryAndCompare("select cast(str as timestamp_ntz) from str_view") {
checkGlutenPlan[ProjectExecTransformer]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,12 @@ object Validators {
case p if HiveTableScanExecTransformer.isHiveTableScan(p) => true
case _ => false
}
val hasNTZ = plan.output.exists(a => containsNTZ(a.dataType)) ||
plan.children.exists(_.output.exists(a => containsNTZ(a.dataType)))
if (isScan || !hasNTZ) {
// Allow nodes that either consume NTZ (e.g. hour(timestamp_ntz) -> int)
// or produce NTZ from non-NTZ input (e.g. cast(string as timestamp_ntz)).
// Only fall back when NTZ propagates unchanged through both input and output.
val inputHasNTZ = plan.children.exists(_.output.exists(a => containsNTZ(a.dataType)))
val outputHasNTZ = plan.output.exists(a => containsNTZ(a.dataType))
if (isScan || !(inputHasNTZ && outputHasNTZ)) {
return pass()
}
}
Expand Down
Loading