spark-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reynold Xin <r...@databricks.com>
Subject Re: And.eval short circuiting
Date Tue, 15 Sep 2015 05:14:46 GMT
rxin=# select null and true;
 ?column?
----------

(1 row)

rxin=# select null and false;
 ?column?
----------
 f
(1 row)


null and false should return false.


On Mon, Sep 14, 2015 at 9:12 PM, Zack Sampson <zsampson@palantir.com> wrote:

> It seems like And.eval can avoid calculating right.eval if left.eval
> returns null. Is there a reason it's written like it is?
>
> override def eval(input: Row): Any = {
>   val l = left.eval(input)
>   if (l == false) {
>     false
>   } else {
>     val r = right.eval(input)
>     if (r == false) {
>       false
>     } else {
>       if (l != null && r != null) {
>         true
>       } else {
>         null
>       }
>     }
>   }
> }
>
>

Mime
View raw message