Skip to content

Commit 52cdc69

Browse files
committed
Addresses comments
1 parent 029f9bd commit 52cdc69

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff 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(

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff 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.

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)