cloud-fan commented on a change in pull request #25902: [SPARK-29213][SQL] Make it consistent when get notnull output and generate null checks in FilterExec URL: https://github.com/apache/spark/pull/25902#discussion_r327523754
########## File path: sql/core/src/main/scala/org/apache/spark/sql/execution/basicPhysicalOperators.scala ########## @@ -110,6 +110,7 @@ case class FilterExec(condition: Expression, child: SparkPlan) // The columns that will filtered out by `IsNotNull` could be considered as not nullable. private val notNullAttributes = notNullPreds.flatMap(_.references).distinct.map(_.exprId) + .diff(otherPreds.flatMap(_.references).distinct.map(_.exprId)) Review comment: I think the bug is about how we codegen null checks, the current logic is: 1. split the predicates into `notNullPreds` (IsNotNull expressions) and `otherPreds` 2. try codegen `otherPreds` first, then `notNullPreds`. 3. if an other-predicate can leverage a specific not-null-predicate, then codegen that not-null-predicate first, so that we can codegen the other-predicate with non-nullable attributes. There is a problem in step 3. Image that we have a `IsNotNull(SubString(a))` and a `SomeFunc(a)`. Then `a` is a not-null attribute for sure, even if there is no `IsNullNull(a)` predicate. When we codegen `SomeFunc(a)`, we can't find a `IsNotNull(a)` expression, so we skip the null check. However, we assume `a` is not nullable when codegen `SomeFunc(a)`, which is wrong as `IsNotNull(SubString(a))` has not been codegened yet. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
