Uh oh!
There was an error while loading. Please reload this page.
[SPARK-13995][SQL] Extract correct IsNotNull constraints for Expression - #11809
[SPARK-13995][SQL] Extract correct IsNotNull constraints for Expression#11809viirya wants to merge 13 commits into
Conversation
gatorsmile
commented
Mar 18, 2016
Yeah, I also hit this issue when fixing this PR: #11765 You are so fast! Actually, they are related. My original plan is to merge the previous one and then revisit this issue. If this is merged before the above PR, I need to redo the work. Anyway, thank you for fixing this issue! |
viirya
commented
Mar 18, 2016
@gatorsmile Thanks for providing the info! I found this issue before when dealing with another PR. But I has no time to submit it separately as new PR until today. |
SparkQA
commented
Mar 18, 2016
Test build #53495 has finished for PR 11809 at commit
|
viirya
commented
Mar 19, 2016
| private def collectCasts(e: Expression): Option[Attribute] = { | ||
| if (e.isInstanceOf[Cast]) { | ||
| collectCasts(e.children(0)) |
There was a problem hiding this comment.
e.child for better readability?
sameeragarwal
commented
Mar 21, 2016
Thanks for fixing this! Just few non-critical suggestions. |
marmbrus
commented
Mar 21, 2016
This fix seems okay, but I feel like we are just adding one-offs instead of taking a step back and thinking about how to generally infer null-intollerance from an expression. For example, after this PR we still aren't doing great in this case: scala>valdf=Seq((1,2,3)).toDF("a", "b", "c")
scala> df.where("a + b = c").queryExecution.analyzed.constraints
res2: org.apache.spark.sql.catalyst.expressions.ExpressionSet=Set(((a#4+ b#5) = c#6), isnotnull((a#4+ b#5)), isnotnull(c#6))Given that it seems most useful to infer We could even consider making |
sameeragarwal
commented
Mar 21, 2016
+1 completely agree with @marmbrus |
gatorsmile
commented
Mar 21, 2016
Yeah, also agree with @marmbrus . This is a general issue. When fixing |
viirya
commented
Mar 22, 2016
@marmbrus Great suggestion. Thanks! I will update this according to your suggestion. |
Conflicts: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/planning/patterns.scala
SparkQA
commented
Mar 22, 2016
Test build #53766 has finished for PR 11809 at commit
|
SparkQA
commented
Mar 22, 2016
Test build #53765 has finished for PR 11809 at commit
|
| private def scanNullIntolerantExpr(expr: Expression): Set[Expression] = expr match { | ||
| case a: Attribute => Set(IsNotNull(a)) | ||
| case IsNotNull(e) => |
There was a problem hiding this comment.
Make it more general. Here, you just cover a single case
SparkQA
commented
Mar 22, 2016
Test build #53771 has finished for PR 11809 at commit
|
SparkQA
commented
Mar 23, 2016
Test build #53903 has finished for PR 11809 at commit
|
viirya
commented
Mar 23, 2016
retest this please. |
SparkQA
commented
Mar 23, 2016
Test build #53927 has finished for PR 11809 at commit
|
viirya
commented
Mar 23, 2016
retest this please. |
SparkQA
commented
Mar 23, 2016
Test build #53917 has finished for PR 11809 at commit
|
SparkQA
commented
Mar 23, 2016
Test build #53929 has finished for PR 11809 at commit
|
viirya
commented
Mar 24, 2016
A not related flaky test... |
viirya
commented
Mar 24, 2016
retest this please. |
SparkQA
commented
Mar 24, 2016
Test build #53999 has finished for PR 11809 at commit
|
SparkQA
commented
Mar 24, 2016
Test build #54012 has finished for PR 11809 at commit
|
viirya
commented
Mar 24, 2016
retest this please. |
SparkQA
commented
Mar 24, 2016
Test build #54022 has finished for PR 11809 at commit
|
viirya
commented
Mar 24, 2016
retest this please. |
viirya
commented
Mar 24, 2016
Any hint about why Tests are passed locally. |
SparkQA
commented
Mar 24, 2016
Test build #54026 has finished for PR 11809 at commit
|
viirya
commented
Mar 24, 2016
retest this please. |
SparkQA
commented
Mar 24, 2016
Test build #54046 has finished for PR 11809 at commit
|
viirya
commented
Mar 24, 2016
@marmbrus@sameeragarwal@gatorsmile This is ready for review now. Thanks! |
Conflicts: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/plans/ConstraintPropagationSuite.scala
viirya
commented
Mar 31, 2016
@marmbrus Can you take a look this? Thanks. |
SparkQA
commented
Mar 31, 2016
Test build #54635 has finished for PR 11809 at commit
|
sameeragarwal
commented
Mar 31, 2016
LGTM, this approach is pretty neat. Thanks! |
viirya
commented
Apr 1, 2016
@sameeragarwal Thanks for reviewing. Waiting for @marmbrus checking this. |
marmbrus
commented
Apr 1, 2016
Thanks, merging to master! |
What changes were proposed in this pull request?
JIRA: https://issues.apache.org/jira/browse/SPARK-13995
We infer relative
IsNotNullconstraints from logical plan's expressions inconstructIsNotNullConstraintsnow. However, we don't consider the case of (nested)Cast.For example:
Then, the plan's constraints will have
IsNotNull(Cast(resolveColumn(tr, "a"), LongType)), instead ofIsNotNull(resolveColumn(tr, "a")). This PR fixes it.Besides, as
IsNotNullconstraints are most useful forAttribute, we should do recursing through anyExpressionthat is null intolerant and constructIsNotNullconstraints for allAttributes under these Expressions.For example, consider the following constraints:
The inferred isnotnull constraints should be isnotnull(a), isnotnull(b), isnotnull(c), instead of isnotnull(a + c) and isnotnull(c).
How was this patch tested?
Test is added into
ConstraintPropagationSuite.