Skip to content

Commit 0c5e6ad

Browse files
committed
Spark 3.4: Fix custom rule ExprUtils$CustomResolveTimeZone
1 parent c025ef3 commit 0c5e6ad

File tree

1 file changed

+9
-14
lines changed
  • spark-3.4/clickhouse-spark/src/main/scala/org/apache/spark/sql/clickhouse

1 file changed

+9
-14
lines changed

spark-3.4/clickhouse-spark/src/main/scala/org/apache/spark/sql/clickhouse/ExprUtils.scala

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,16 @@ object ExprUtils extends SQLConfHelper with Serializable {
106106
}
107107

108108
private class CustomResolveTimeZone(timeZoneId: Option[String]) extends Rule[LogicalPlan] {
109-
private val transformTimeZoneExprs: PartialFunction[Expression, Expression] = {
110-
case e: TimeZoneAwareExpression if e.timeZoneId.isEmpty =>
111-
e.withTimeZone(timeZoneId.getOrElse(conf.sessionLocalTimeZone))
112-
// Casts could be added in the subquery plan through the rule TypeCoercion while coercing
113-
// the types between the value expression and list query expression of IN expression.
114-
// We need to subject the subquery plan through ResolveTimeZone again to setup timezone
115-
// information for time zone aware expressions.
116-
case e: ListQuery => e.withNewPlan(apply(e.plan))
117-
}
118-
119109
override def apply(plan: LogicalPlan): LogicalPlan =
120-
plan.resolveExpressionsWithPruning(
121-
_.containsAnyPattern(LIST_SUBQUERY, TIME_ZONE_AWARE_EXPRESSION),
122-
ruleId
123-
)(transformTimeZoneExprs)
110+
plan.resolveExpressionsWithPruning(_.containsAnyPattern(LIST_SUBQUERY, TIME_ZONE_AWARE_EXPRESSION)) {
111+
case e: TimeZoneAwareExpression if e.timeZoneId.isEmpty =>
112+
e.withTimeZone(timeZoneId.getOrElse(conf.sessionLocalTimeZone))
113+
// Casts could be added in the subquery plan through the rule TypeCoercion while coercing
114+
// the types between the value expression and list query expression of IN expression.
115+
// We need to subject the subquery plan through ResolveTimeZone again to setup timezone
116+
// information for time zone aware expressions.
117+
case e: ListQuery => e.withNewPlan(apply(e.plan))
118+
}
124119
}
125120

126121
private class TypeCoercionExecutor(timeZoneId: Option[String]) extends RuleExecutor[LogicalPlan] {

0 commit comments

Comments
 (0)