Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9123#discussion_r42089770
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala
 ---
    @@ -135,4 +135,21 @@ class AnalysisSuite extends AnalysisTest {
         plan = testRelation.select(CreateStructUnsafe(Seq(a, (a + 
1).as("a+1"))).as("col"))
         checkAnalysis(plan, plan)
       }
    +
    +  test("SPARK-10534: resolve attribute references in order by clause") {
    +
    +    val a = testRelation2.output.head
    +    val c = testRelation2.output.toArray.apply(2)
    +
    +    val sortProjected = Floor(Cast(Floor(c), DoubleType))
    +    val projected = Alias(a, "a")()
    +    val plan = testRelation2.select(a).orderBy(SortOrder(Floor(Floor(c)), 
Ascending))
    +
    +    val expected =
    +      Project(Seq(a),
    +        Sort(Seq(SortOrder(sortProjected, Ascending)), true,
    +          Project(Seq(a, c), testRelation2)))
    +    checkAnalysis(plan, expected)
    +
    +  }
    --- End diff --
    
    the test case can be simplified to:
    ```
        val a = testRelation2.output(0)
        val c = testRelation2.output(2)
    
        val plan = testRelation2.select(c).orderBy(Floor(a).asc)
        val expected = testRelation2.select(c, 
a).orderBy(Floor(a.cast(DoubleType)).asc).select(c)
    
        checkAnalysis(plan, expected)
    ```


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