cloud-fan commented on code in PR #48621:
URL: https://github.com/apache/spark/pull/48621#discussion_r1813034529
##########
sql/core/src/main/scala/org/apache/spark/sql/catalyst/util/V2ExpressionBuilder.scala:
##########
@@ -221,8 +221,18 @@ class V2ExpressionBuilder(e: Expression, isPredicate:
Boolean = false) extends L
case _: BitwiseNot => generateExpressionWithName("~", expr, isPredicate)
case caseWhen @ CaseWhen(branches, elseValue) =>
val conditions = branches.map(_._1).flatMap(generateExpression(_, true))
- val values = branches.map(_._2).flatMap(generateExpression(_))
- val elseExprOpt = elseValue.flatMap(generateExpression(_))
+ val values = branches.map(_._2).flatMap(child =>
+ generateExpression(
+ child,
+ isPredicate && child.dataType.isInstanceOf[BooleanType]
Review Comment:
do we need `child.dataType.isInstanceOf[BooleanType]`? I think
`generateExpression` only use v2 Predicate if the expression data type is
boolean
##########
sql/core/src/main/scala/org/apache/spark/sql/catalyst/util/V2ExpressionBuilder.scala:
##########
@@ -221,8 +221,18 @@ class V2ExpressionBuilder(e: Expression, isPredicate:
Boolean = false) extends L
case _: BitwiseNot => generateExpressionWithName("~", expr, isPredicate)
case caseWhen @ CaseWhen(branches, elseValue) =>
val conditions = branches.map(_._1).flatMap(generateExpression(_, true))
- val values = branches.map(_._2).flatMap(generateExpression(_))
- val elseExprOpt = elseValue.flatMap(generateExpression(_))
+ val values = branches.map(_._2).flatMap(child =>
+ generateExpression(
+ child,
+ isPredicate && child.dataType.isInstanceOf[BooleanType]
+ )
+ )
+ val elseExprOpt = elseValue.flatMap(child =>
+ generateExpression(
+ child,
+ isPredicate && child.dataType.isInstanceOf[BooleanType]
Review Comment:
ditto
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]