Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ object QueryPlan extends PredicateHelper {
if (ordinal == -1) {
ar
} else {
ar.withExprId(ExprId(ordinal))
ar.withExprId(ExprId(ordinal)).canonicalized
}
}.canonicalized.asInstanceOf[T]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
package org.apache.spark.sql.execution

import org.apache.spark.sql.{DataFrame, QueryTest}
import org.apache.spark.sql.catalyst.expressions.AttributeReference
import org.apache.spark.sql.catalyst.plans.logical.{LocalRelation, Project}
import org.apache.spark.sql.functions._
import org.apache.spark.sql.test.SharedSQLContext
import org.apache.spark.sql.types.IntegerType

/**
* Tests for the sameResult function for [[SparkPlan]]s.
Expand Down Expand Up @@ -58,4 +61,16 @@ class SameResultSuite extends QueryTest with SharedSQLContext {
val df4 = spark.range(10).agg(sumDistinct($"id"))
assert(df3.queryExecution.executedPlan.sameResult(df4.queryExecution.executedPlan))
}

test("Canonicalized result is case-insensitive") {
val a = AttributeReference("A", IntegerType)()
val b = AttributeReference("B", IntegerType)()
val planUppercase = Project(Seq(a), LocalRelation(a, b))

val c = AttributeReference("a", IntegerType)()
val d = AttributeReference("b", IntegerType)()
val planLowercase = Project(Seq(c), LocalRelation(c, d))

assert(planUppercase.sameResult(planLowercase))
}
}