Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ object BooleanSimplification extends Rule[LogicalPlan] with PredicateHelper {
case Not(a And b) => Or(Not(a), Not(b))

case Not(Not(e)) => e

case Not(IsNull(e)) => IsNotNull(e)
case Not(IsNotNull(e)) => IsNull(e)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ class BooleanSimplificationSuite extends PlanTest with ExpressionEvalHelper with
checkCondition(!'f || 'e, testRelationWithData.where(!'f || 'e).analyze)
}

test("simplify NOT(IsNull(x)) and NOT(IsNotNull(x))") {
checkCondition(Not(IsNotNull('b)), IsNull('b))
checkCondition(Not(IsNull('b)), IsNotNull('b))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AngersZhuuuu . Since you are active contribution, I'd like to recommend to use DSL as possible as you can. (Please refer the other tests.)

  test("simplify NOT(IsNull(x)) and NOT(IsNotNull(x))") {
    checkCondition(Not(IsNotNull('e)), IsNull('e))
    checkCondition(Not(IsNull('e)), IsNotNull('e))
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AngersZhuuuu . Since you are active contribution, I'd like to recommend to use DSL as possible as you can. (Please refer the other tests.)

First time use DSL, I will get to know DSL more


protected def assertEquivalent(e1: Expression, e2: Expression): Unit = {
val correctAnswer = Project(Alias(e2, "out")() :: Nil, OneRowRelation()).analyze
val actual = Optimize.execute(Project(Alias(e1, "out")() :: Nil, OneRowRelation()).analyze)
Expand Down