Skip to content

Commit

Permalink
fix bug in or/and short-circuit evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
chenghao-intel committed May 16, 2014
1 parent af2236b commit a08f09c
Showing 1 changed file with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,18 @@ case class And(left: Expression, right: Expression) extends BinaryPredicate {

override def eval(input: Row): Any = {
val l = left.eval(input)
if(l == null) {
null
} else if(l == false) {
false
if(l == false) {
false
} else {
val r = right.eval(input)
if(r == null) {
null
if(r == false) {
false
} else {
r
if(l != null && r != null) {
true
} else {
null
}
}
}
}
Expand All @@ -118,16 +120,18 @@ case class Or(left: Expression, right: Expression) extends BinaryPredicate {

override def eval(input: Row): Any = {
val l = left.eval(input)
if(l == null) {
null
} else if(l == true) {
if(l == true) {
true
} else {
val r = right.eval(input)
if(r == null) {
null
if(r == true) {
true
} else {
r
if(l != null && r != null) {
false
} else {
null
}
}
}
}
Expand Down

0 comments on commit a08f09c

Please sign in to comment.