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 @@ -154,11 +154,17 @@ object NormalizePlan extends PredicateHelper {
.getTagValue(DeduplicateRelations.PROJECT_FOR_EXPRESSION_ID_DEDUPLICATION)
.isDefined =>
project.child
case aggregate @ Aggregate(_, _, innerProject: Project, _) =>
val newInnerProject = Project(
innerProject.projectList.sortBy(_.name),
innerProject.child
)
aggregate.copy(child = newInnerProject)
case Project(outerProjectList, innerProject: Project) =>
val normalizedInnerProjectList = normalizeProjectList(innerProject.projectList)
val orderedInnerProjectList = normalizedInnerProjectList.sortBy(_.name)
val newInnerProject =
Project(orderedInnerProjectList, innerProject.child)
val newInnerProject = Project(
innerProject.projectList.sortBy(_.name),
innerProject.child
)
Project(normalizeProjectList(outerProjectList), newInnerProject)
case Project(projectList, child) =>
Project(normalizeProjectList(projectList), child)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class NormalizePlanSuite extends SparkFunSuite with SQLConfHelper {
assert(NormalizePlan(baselinePlan) == NormalizePlan(testPlan))
}

test("Normalize ordering in a project list of an inner Project") {
test("Normalize ordering in a project list of an inner Project under Project") {
val baselinePlan =
LocalRelation($"col1".int, $"col2".string).select($"col1", $"col2").select($"col1")
val testPlan =
Expand All @@ -58,6 +58,16 @@ class NormalizePlanSuite extends SparkFunSuite with SQLConfHelper {
assert(NormalizePlan(baselinePlan) == NormalizePlan(testPlan))
}

test("Normalize ordering in a project list of an inner Project under Aggregate") {
val baselinePlan =
LocalRelation($"col1".int, $"col2".string).select($"col1", $"col2").groupBy($"col1")($"col1")
val testPlan =
LocalRelation($"col1".int, $"col2".string).select($"col2", $"col1").groupBy($"col1")($"col1")

assert(baselinePlan != testPlan)
assert(NormalizePlan(baselinePlan) == NormalizePlan(testPlan))
}

test("Normalize InheritAnalysisRules expressions") {
val castWithoutTimezone =
Cast(child = Literal(1), dataType = BooleanType, ansiEnabled = conf.ansiEnabled)
Expand Down