kazuyukitanimura commented on a change in pull request #33930:
URL: https://github.com/apache/spark/pull/33930#discussion_r719867484
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -797,6 +834,19 @@ object NullPropagation extends Rule[LogicalPlan] {
// a null literal.
case e: NullIntolerant if e.children.exists(isNullLiteral) =>
Literal.create(null, e.dataType)
+
+ // [SPARK-36665] Unwrap inside of IsNull/IsNotNull if the inside is
NullIntolerant
+ // E.g. IsNull(Not(null)) == IsNull(null)
+ // Cannot apply to `ExtractValue` as the query planner uses the trait to
resolve the columns.
+ // E.g. the planner may resolve column `a` to `a#123`, then
IsNull(a#123) cannot be optimized
+ // UnaryExpression only for now as applying this optimization to other
expressions is too
+ // disruptive for some tests (e.g. [SPARK-32290].) TODO remove
e.isInstanceOf[UnaryExpression]
+ case IsNull(e: NullIntolerant) if e.isInstanceOf[UnaryExpression] &&
Review comment:
I ended up addressing this by limiting the e to be from selected list of
NullIntolerant expressions only, as I found not all NullIntolerant can be
supported. I can think of an extreme example e that is non-deterministic but
guarantees not to return null unless children are null. So deterministic check
is not necessary.
--
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]