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

    https://github.com/apache/spark/pull/15489#discussion_r83500257
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala 
---
    @@ -1106,6 +1106,30 @@ class SQLQuerySuite extends QueryTest with 
SharedSQLContext {
         )
       }
     
    +  test("SPARK-17863: SELECT distinct does not work correctly if order by 
missing attribute") {
    +    checkAnswer(
    +      sql("""select distinct struct.a, struct.b
    +          |from (
    +          |  select named_struct('a', 1, 'b', 2, 'c', 3) as struct
    +          |  union all
    +          |  select named_struct('a', 1, 'b', 2, 'c', 4) as struct) tmp
    +          |order by a, b
    +          |""".stripMargin),
    +      Row(1, 2) :: Nil)
    +
    +    val error = intercept[AnalysisException] {
    +      sql("""select distinct struct.a, struct.b
    +            |from (
    +            |  select named_struct('a', 1, 'b', 2, 'c', 3) as struct
    +            |  union all
    +            |  select named_struct('a', 1, 'b', 2, 'c', 4) as struct) tmp
    +            |order by struct.a, struct.b
    +            |""".stripMargin)
    +    }
    +    assert(error.message contains "cannot resolve '`struct.a`' given input 
columns: [a, b]")
    --- End diff --
    
    Oh, i see. Seems this error is thrown by check analysis, which does not 
have info about what is the query. So, it is hard to figure out what messages 
(for the workaround) to put at here.


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