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 @@ -1521,4 +1521,27 @@ abstract class ScalarFunctionsValidateSuite extends FunctionsValidateSuite {
}
}
}
test("test_current_timestamp") {
val df = spark.sql("SELECT l_orderkey, current_timestamp() from lineitem limit 1")
val optimizedPlan = df.queryExecution.optimizedPlan.toString()
assert(
!optimizedPlan.contains("CurrentTimestamp"),
s"Expected CurrentTimestamp to be folded to a literal, but got: $optimizedPlan"
)
checkGlutenPlan[ProjectExecTransformer](df)
checkFallbackOperators(df, 0)
df.collect()
}

test("test_now") {
val df = spark.sql("SELECT l_orderkey, now() from lineitem limit 1")
val optimizedPlan = df.queryExecution.optimizedPlan.toString()
assert(
!optimizedPlan.contains("Now"),
s"Expected Now to be folded to a literal, but got: $optimizedPlan"
)
checkGlutenPlan[ProjectExecTransformer](df)
checkFallbackOperators(df, 0)
df.collect()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,28 @@ object Validators {

private class FallbackByTimestampNTZ() extends Validator {
override def validate(plan: SparkPlan): Validator.OutCome = {
// Check if TimestampNTZ validation is enabled via VeloxConfig
// Use reflection to avoid compile-time dependency on backends-velox module
val enableValidation =
try {
// scalastyle:off classforname
val veloxConfigClass = Class.forName("org.apache.gluten.config.VeloxConfig")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// scalastyle:on classforname
val getMethod = veloxConfigClass.getMethod("get")
val configInstance = getMethod.invoke(null)
val enableMethod = veloxConfigClass.getMethod("enableTimestampNtzValidation")
enableMethod.invoke(configInstance).asInstanceOf[Boolean]
} catch {
case _: Exception =>
// If VeloxConfig is not available (e.g., non-Velox backend), default to enabled
true
}

if (!enableValidation) {
// Validation is disabled, allow TimestampNTZ
return pass()
}

def containsNTZ(dataType: DataType): Boolean = dataType match {
case dt if dt.catalogString == "timestamp_ntz" => true
case st: StructType => st.exists(f => containsNTZ(f.dataType))
Expand Down
Loading
Loading