Github user jaceklaskowski commented on a diff in the pull request: https://github.com/apache/spark/pull/14444#discussion_r73337237 --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala --- @@ -218,9 +221,44 @@ class AnalysisSuite extends AnalysisTest { // CreateStruct is a special case that we should not trim Alias for it. plan = testRelation.select(CreateStruct(Seq(a, (a + 1).as("a+1"))).as("col")) - checkAnalysis(plan, plan) + expected = testRelation.select(CreateNamedStruct(Seq( + Literal(a.name), a, + Literal("a+1"),(a + 1))).as("col")) + checkAnalysis(plan, expected) plan = testRelation.select(CreateStructUnsafe(Seq(a, (a + 1).as("a+1"))).as("col")) - checkAnalysis(plan, plan) + expected = testRelation.select(CreateNamedStructUnsafe(Seq( + Literal(a.name), a, + Literal("a+1"),(a + 1))).as("col")) + checkAnalysis(plan, expected) + } + + test("Analysis may leave unnecassary aliases") { + val att1 = testRelation.output.head + var plan = testRelation.select( + CreateStructUnsafe(Seq(att1, ((att1 as "aa") + 1).as("a_plus_1"))).as("col"), + att1 + ) + val prevPlan = getAnalyzer(true).execute(plan) + plan = prevPlan.select(CreateArray(Seq( + CreateStructUnsafe(Seq(att1, (att1 + 1).as("a_plus_1"))), + /** alias should be eliminated by [[CleanupAliases]] */ + "col".attr as "col2" + )) as "arr") + plan = getAnalyzer(true).execute(plan) + + plan should be (a[Project]) + val Project( projectExpressions, _) = plan --- End diff -- Space?
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org