Skip to content

Commit

Permalink
Addresses comments
Browse files Browse the repository at this point in the history
  • Loading branch information
liancheng committed Mar 23, 2015
1 parent 029f9bd commit 52cdc69
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ class CheckAnalysis {
}

operator match {
case o if o.children.nonEmpty &&
!o.references.filter(_.name != "grouping__id").subsetOf(o.inputSet) =>
val missingAttributes = (o.references -- o.inputSet).mkString(",")
case o if o.children.nonEmpty && o.missingInput.nonEmpty =>
val missingAttributes = o.missingInput.mkString(",")
val input = o.inputSet.mkString(",")

failAnalysis(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ abstract class QueryPlan[PlanType <: TreeNode[PlanType]] extends TreeNode[PlanTy
* Attributes that are referenced by expressions but not provided by this nodes children.
* Subclasses should override this method if they produce attributes internally as it is used by
* assertions designed to prevent the construction of invalid plans.
*
* Note that virtual columns should be excluded. Currently, we only support the grouping ID
* virtual column.
*/
def missingInput: AttributeSet = (references -- inputSet)
.filter(_.name != VirtualColumn.groupingIdName)
def missingInput: AttributeSet =
(references -- inputSet).filter(_.name != VirtualColumn.groupingIdName)

/**
* Runs [[transform]] with `rule` on all expressions present in this query operator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ class AnalysisSuite extends FunSuite with BeforeAndAfter {
assert(pl(4).dataType == DoubleType)
}

test("SPARK-6452: CheckAnalysis should throw when Aggregate contains missing attributes") {
test("SPARK-6452 regression test") {
// CheckAnalysis should throw AnalysisException when Aggregate contains missing attribute(s)
val plan =
Aggregate(
Nil,
Expand Down

0 comments on commit 52cdc69

Please sign in to comment.