You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/08/28 07:30:57 UTC

[GitHub] [spark] tanelk commented on pull request #29567: [WIP][SPARK-32721][SQL] Simplify if clauses with null and boolean

tanelk commented on pull request #29567:
URL: https://github.com/apache/spark/pull/29567#issuecomment-682375454


   Are you sure these rules are correct?
   The first one seems to fail if p is false
   And the seconds one seems to fail on all 3 values
   
   I tried a quick test and 4 out of 6 of these failed.
   ```
     val nullLiteral = Literal(null, BooleanType)
   
     Seq(Literal.TrueLiteral, Literal.FalseLiteral, nullLiteral).foreach(p => {
       assertEquivalent(If(p, nullLiteral, Literal.FalseLiteral), And(p, nullLiteral))
       assertEquivalent(If(p, nullLiteral, Literal.TrueLiteral), Or(p, nullLiteral))
     })
   
     private def assertEquivalent(e1: Expression, e2: Expression): Unit = {
       test("SPARK-32721: " + e1.toString) {
         checkEvaluation (e1, e2.eval (EmptyRow) )
       }
     }
   ```
   
   It seem that there might be some sort of equivalence here, but I'm not 100% sure how it should look like.


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org