Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22857#discussion_r236098905
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
 ---
    @@ -736,3 +736,60 @@ object CombineConcats extends Rule[LogicalPlan] {
           flattenConcats(concat)
       }
     }
    +
    +/**
    + * A rule that replaces `Literal(null, _)` with `FalseLiteral` for further 
optimizations.
    + *
    + * This rule applies to conditions in [[Filter]] and [[Join]]. Moreover, 
it transforms predicates
    + * in all [[If]] expressions as well as branch conditions in all 
[[CaseWhen]] expressions.
    + *
    + * For example, `Filter(Literal(null, _))` is equal to 
`Filter(FalseLiteral)`.
    + *
    + * Another example containing branches is `Filter(If(cond, FalseLiteral, 
Literal(null, _)))`;
    + * this can be optimized to `Filter(If(cond, FalseLiteral, 
FalseLiteral))`, and eventually
    + * `Filter(FalseLiteral)`.
    + *
    + * As this rule is not limited to conditions in [[Filter]] and [[Join]], 
arbitrary plans can
    + * benefit from it. For example, `Project(If(And(cond, Literal(null)), 
Literal(1), Literal(2)))`
    + * can be simplified into `Project(Literal(2))`.
    + *
    + * As a result, many unnecessary computations can be removed in the query 
optimization phase.
    + */
    +object ReplaceNullWithFalse extends Rule[LogicalPlan] {
    --- End diff --
    
    Let us move it to a new file. The file is growing too big. 


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to