Skip to content

Commit 7cd6844

Browse files
author
Davies Liu
committed
address comments
1 parent 7df43ca commit 7cd6844

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,12 @@ abstract class QueryPlan[PlanType <: QueryPlan[PlanType]] extends TreeNode[PlanT
257257
* can do better should override this function.
258258
*/
259259
def sameResult(plan: PlanType): Boolean = {
260-
val cleanLeft = this.canonicalized
261-
val cleanRight = plan.canonicalized
262-
cleanLeft.getClass == cleanRight.getClass &&
263-
cleanLeft.children.size == cleanRight.children.size &&
264-
cleanLeft.cleanArgs == cleanRight.cleanArgs &&
265-
(cleanLeft.children, cleanRight.children).zipped.forall(_ sameResult _)
260+
val canonicalizedLeft = this.canonicalized
261+
val canonicalizedRight = plan.canonicalized
262+
canonicalizedLeft.getClass == canonicalizedRight.getClass &&
263+
canonicalizedLeft.children.size == canonicalizedRight.children.size &&
264+
canonicalizedLeft.cleanArgs == canonicalizedRight.cleanArgs &&
265+
(canonicalizedLeft.children, canonicalizedRight.children).zipped.forall(_ sameResult _)
266266
}
267267

268268
/**
@@ -291,7 +291,7 @@ abstract class QueryPlan[PlanType <: QueryPlan[PlanType]] extends TreeNode[PlanT
291291
productIterator.map {
292292
// Children are checked using sameResult above.
293293
case tn: TreeNode[_] if containsChild(tn) => null
294-
case e: Expression => cleanExpression(e)
294+
case e: Expression => cleanArg(e)
295295
case s: Option[_] => s.map(cleanArg)
296296
case s: Seq[_] => s.map(cleanArg)
297297
case m: Map[_, _] => m.mapValues(cleanArg)

sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,12 +1337,17 @@ class DataFrameSuite extends QueryTest with SharedSQLContext {
13371337
}
13381338
}
13391339

1340-
test("same result on aggregate") {
1340+
test("sameResult() on aggregate") {
13411341
val df = sqlContext.range(100)
13421342
val agg1 = df.groupBy().count()
13431343
val agg2 = df.groupBy().count()
13441344
// two aggregates with different ExprId within them should have same result
1345-
agg1.queryExecution.executedPlan.sameResult(agg2.queryExecution.executedPlan)
1345+
assert(agg1.queryExecution.executedPlan.sameResult(agg2.queryExecution.executedPlan))
1346+
val agg3 = df.groupBy().sum()
1347+
assert(!agg1.queryExecution.executedPlan.sameResult(agg3.queryExecution.executedPlan))
1348+
val df2 = sqlContext.range(101)
1349+
val agg4 = df2.groupBy().count()
1350+
assert(!agg1.queryExecution.executedPlan.sameResult(agg4.queryExecution.executedPlan))
13461351
}
13471352

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

0 commit comments

Comments
 (0)