Github user jaceklaskowski commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14444#discussion_r73337483
  
    --- 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
    +    projectExpressions should have (size(1))
    +    val Seq(expr1) = projectExpressions
    +    expr1 should be (a[Alias])
    +    val Alias(expr2, arrAlias) = expr1
    +    arrAlias shouldBe "arr"
    +    expr2 should be (a[CreateArray])
    +    val CreateArray(arrElements) = expr2
    +    arrElements should have (size(2))
    +    val Seq(el1, el2) = arrElements
    +    el1 should not be a[Alias]
    --- End diff --
    
    Why no `(` since you've been using them in `should be`'s earlier?


---
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

Reply via email to