File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed
main/scala/org/apache/spark/sql/catalyst
test/scala/org/apache/spark/sql/catalyst/analysis Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -89,9 +89,8 @@ class CheckAnalysis {
8989 }
9090
9191 operator match {
92- case o if o.children.nonEmpty &&
93- ! o.references.filter(_.name != " grouping__id" ).subsetOf(o.inputSet) =>
94- val missingAttributes = (o.references -- o.inputSet).mkString(" ," )
92+ case o if o.children.nonEmpty && o.missingInput.nonEmpty =>
93+ val missingAttributes = o.missingInput.mkString(" ," )
9594 val input = o.inputSet.mkString(" ," )
9695
9796 failAnalysis(
Original file line number Diff line number Diff line change @@ -47,9 +47,12 @@ abstract class QueryPlan[PlanType <: TreeNode[PlanType]] extends TreeNode[PlanTy
4747 * Attributes that are referenced by expressions but not provided by this nodes children.
4848 * Subclasses should override this method if they produce attributes internally as it is used by
4949 * assertions designed to prevent the construction of invalid plans.
50+ *
51+ * Note that virtual columns should be excluded. Currently, we only support the grouping ID
52+ * virtual column.
5053 */
51- def missingInput : AttributeSet = (references -- inputSet)
52- .filter(_.name != VirtualColumn .groupingIdName)
54+ def missingInput : AttributeSet =
55+ (references -- inputSet) .filter(_.name != VirtualColumn .groupingIdName)
5356
5457 /**
5558 * Runs [[transform ]] with `rule` on all expressions present in this query operator.
Original file line number Diff line number Diff line change @@ -200,7 +200,8 @@ class AnalysisSuite extends FunSuite with BeforeAndAfter {
200200 assert(pl(4 ).dataType == DoubleType )
201201 }
202202
203- test(" SPARK-6452: CheckAnalysis should throw when Aggregate contains missing attributes" ) {
203+ test(" SPARK-6452 regression test" ) {
204+ // CheckAnalysis should throw AnalysisException when Aggregate contains missing attribute(s)
204205 val plan =
205206 Aggregate (
206207 Nil ,
You can’t perform that action at this time.
0 commit comments