diff options
author | Sameer Agarwal <sameer@databricks.com> | 2016-03-25 12:57:26 -0700 |
---|---|---|
committer | Davies Liu <davies.liu@gmail.com> | 2016-03-25 12:57:26 -0700 |
commit | afd0debe075e9ea8466e384932a513ef0188273c (patch) | |
tree | 008fa22edf6907e460920b975aebb0333a5f1f84 /sql/catalyst/src/test | |
parent | ca003354da5e738e97418efc5af07be071c16d8f (diff) | |
download | spark-afd0debe075e9ea8466e384932a513ef0188273c.tar.gz spark-afd0debe075e9ea8466e384932a513ef0188273c.tar.bz2 spark-afd0debe075e9ea8466e384932a513ef0188273c.zip |
[SPARK-14137] [SPARK-14150] [SQL] Infer IsNotNull constraints from non-nullable attributes
## What changes were proposed in this pull request?
This PR adds support for automatically inferring `IsNotNull` constraints from any non-nullable attributes that are part of an operator's output. This also fixes the issue that causes the optimizer to hit the maximum number of iterations for certain queries in https://github.com/apache/spark/pull/11828.
## How was this patch tested?
Unit test in `ConstraintPropagationSuite`
Author: Sameer Agarwal <sameer@databricks.com>
Closes #11953 from sameeragarwal/infer-isnotnull.
Diffstat (limited to 'sql/catalyst/src/test')
-rw-r--r-- | sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/plans/ConstraintPropagationSuite.scala | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/plans/ConstraintPropagationSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/plans/ConstraintPropagationSuite.scala index f3ab026192..e5063599a3 100644 --- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/plans/ConstraintPropagationSuite.scala +++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/plans/ConstraintPropagationSuite.scala @@ -23,6 +23,7 @@ import org.apache.spark.sql.catalyst.dsl.expressions._ import org.apache.spark.sql.catalyst.dsl.plans._ import org.apache.spark.sql.catalyst.expressions._ import org.apache.spark.sql.catalyst.plans.logical._ +import org.apache.spark.sql.types.{IntegerType, StringType} class ConstraintPropagationSuite extends SparkFunSuite { @@ -217,4 +218,12 @@ class ConstraintPropagationSuite extends SparkFunSuite { IsNotNull(resolveColumn(tr, "a")), IsNotNull(resolveColumn(tr, "b"))))) } + + test("infer IsNotNull constraints from non-nullable attributes") { + val tr = LocalRelation('a.int, AttributeReference("b", IntegerType, nullable = false)(), + AttributeReference("c", StringType, nullable = false)()) + + verifyConstraints(tr.analyze.constraints, + ExpressionSet(Seq(IsNotNull(resolveColumn(tr, "b")), IsNotNull(resolveColumn(tr, "c"))))) + } } |