Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
address comments
  • Loading branch information
Davies Liu committed Mar 9, 2016
commit 7cd6844bb405bfe66285a60b58cd583f86f1a2cb
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ abstract class QueryPlan[PlanType <: QueryPlan[PlanType]] extends TreeNode[PlanT
* can do better should override this function.
*/
def sameResult(plan: PlanType): Boolean = {
val cleanLeft = this.canonicalized
val cleanRight = plan.canonicalized
cleanLeft.getClass == cleanRight.getClass &&
cleanLeft.children.size == cleanRight.children.size &&
cleanLeft.cleanArgs == cleanRight.cleanArgs &&
(cleanLeft.children, cleanRight.children).zipped.forall(_ sameResult _)
val canonicalizedLeft = this.canonicalized
val canonicalizedRight = plan.canonicalized
canonicalizedLeft.getClass == canonicalizedRight.getClass &&
canonicalizedLeft.children.size == canonicalizedRight.children.size &&
canonicalizedLeft.cleanArgs == canonicalizedRight.cleanArgs &&
(canonicalizedLeft.children, canonicalizedRight.children).zipped.forall(_ sameResult _)
}

/**
Expand Down Expand Up @@ -291,7 +291,7 @@ abstract class QueryPlan[PlanType <: QueryPlan[PlanType]] extends TreeNode[PlanT
productIterator.map {
// Children are checked using sameResult above.
case tn: TreeNode[_] if containsChild(tn) => null
case e: Expression => cleanExpression(e)
case e: Expression => cleanArg(e)
case s: Option[_] => s.map(cleanArg)
case s: Seq[_] => s.map(cleanArg)
case m: Map[_, _] => m.mapValues(cleanArg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1337,12 +1337,17 @@ class DataFrameSuite extends QueryTest with SharedSQLContext {
}
}

test("same result on aggregate") {
test("sameResult() on aggregate") {
val df = sqlContext.range(100)
val agg1 = df.groupBy().count()
val agg2 = df.groupBy().count()
// two aggregates with different ExprId within them should have same result
agg1.queryExecution.executedPlan.sameResult(agg2.queryExecution.executedPlan)
assert(agg1.queryExecution.executedPlan.sameResult(agg2.queryExecution.executedPlan))
val agg3 = df.groupBy().sum()
assert(!agg1.queryExecution.executedPlan.sameResult(agg3.queryExecution.executedPlan))
val df2 = sqlContext.range(101)
val agg4 = df2.groupBy().count()
assert(!agg1.queryExecution.executedPlan.sameResult(agg4.queryExecution.executedPlan))
}

test("SPARK-12512: support `.` in column name for withColumn()") {
Expand Down