Skip to content

Conversation

@cloud-fan
Copy link
Contributor

@cloud-fan cloud-fan commented Oct 13, 2018

What changes were proposed in this pull request?

improve the code comment added in https://github.com/apache/spark/pull/22702/files

How was this patch tested?

N/A

@cloud-fan cloud-fan changed the title [SPARK-25714] improve the comment inside BooleanSimplification rule [SPARK-25714][SQL][followup] improve the comment inside BooleanSimplification rule Oct 13, 2018
// See the chart:
// +---------+---------+---------+---------+
// | p | q | p OR q | p AND q |
// | operand | operand | OR | AND |
Copy link
Contributor Author

Choose a reason for hiding this comment

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

AND and OR is commutative, so we can reduce the entries in this table

// | UNKNOWN | UNKNOWN | UNKNOWN | UNKNOWN |
// +---------+---------+---------+---------+

// This can break if a is null and c is false, so a can't be nullable.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

explain which input can break it, so it's easier to understand.

Copy link
Member

Choose a reason for hiding this comment

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

The current code will not break. Thus, the comment is confusing to the future reader. To make it clear, we can just give the actual value.

(NULL And (NULL Or FALSE)) = NULL, but (NULL And FALSE) = FALSE. Thus, a can't be nullable.

case (a Or b) And c if !a.nullable && a.semanticEquals(Not(c)) => And(b, c)
case (a Or b) And c if !b.nullable && b.semanticEquals(Not(c)) => And(a, c)
// This can break if c is null and b is false, so c can't be nullable.
case (a Or b) And c if !c.nullable && a.semanticEquals(Not(c)) => And(b, c)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

b.nullable and c.nullable are same, because a.semanticEquals(Not(c)).

@cloud-fan
Copy link
Contributor Author

cc @gatorsmile

@SparkQA
Copy link

SparkQA commented Oct 13, 2018

Test build #97332 has finished for PR 22711 at commit 02e6100.

  • This patch fails MiMa tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Oct 13, 2018

Test build #97334 has finished for PR 22711 at commit 21dab84.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@kiszk
Copy link
Member

kiszk commented Oct 13, 2018

retest this please

@SparkQA
Copy link

SparkQA commented Oct 13, 2018

Test build #97342 has finished for PR 22711 at commit 21dab84.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

asfgit pushed a commit that referenced this pull request Oct 13, 2018
…fication rule

## What changes were proposed in this pull request?

improve the code comment added in https://github.com/apache/spark/pull/22702/files

## How was this patch tested?

N/A

Closes #22711 from cloud-fan/minor.

Authored-by: Wenchen Fan <wenchen@databricks.com>
Signed-off-by: gatorsmile <gatorsmile@gmail.com>
(cherry picked from commit b73f76b)
Signed-off-by: gatorsmile <gatorsmile@gmail.com>
@gatorsmile
Copy link
Member

LGTM

Thanks! Merged to master/2.4

@asfgit asfgit closed this in b73f76b Oct 13, 2018
jackylee-ch pushed a commit to jackylee-ch/spark that referenced this pull request Feb 18, 2019
…fication rule

## What changes were proposed in this pull request?

improve the code comment added in https://github.com/apache/spark/pull/22702/files

## How was this patch tested?

N/A

Closes apache#22711 from cloud-fan/minor.

Authored-by: Wenchen Fan <wenchen@databricks.com>
Signed-off-by: gatorsmile <gatorsmile@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants