Github user zhichao-li commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8811#discussion_r40047528
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala 
---
    @@ -1116,6 +1116,18 @@ class SQLQuerySuite extends QueryTest with 
SQLTestUtils with TestHiveSingleton {
         checkAnswer(sql("SELECT a.`c.b`, `b.$q`[0].`a@!.q`, `q.w`.`w.i&`[0] 
FROM t"), Row(1, 1, 1))
       }
     
    +  test("SPARK-10656: select(df(*)) fails when a column has special 
characters") {
    +    // user should backtick the name if the column with special character 
'.'
    +    // otherwise it's hard to differentiate the intention of "a.b" and 
"g.f"
    +    val df = sqlContext.read.json(sqlContext.sparkContext.makeRDD(
    +      """{"a.b": 10, "d": 11, "f": {"g": 12} }""" :: Nil))
    +    checkAnswer(df.select("f.g"), Row(12))
    +    checkAnswer(df.select("`a.b`"), Row(10))
    +    checkAnswer(df.select("*"), Row(10, 11, Row(12)))
    +    checkAnswer(df.withColumnRenamed("f", "h").select("h"), Row(Row(12)))
    +    checkAnswer(df.withColumnRenamed("f", "h").select("`a.b`"), Row(10))
    --- End diff --
    
    Just add more test to cover the if branch you mentioned. and the below 
items would fail if without this patch.
    ``` scala
    
        checkAnswer(df.select(df("*")), Row(10, 11, Row(12)))
        checkAnswer(df.withColumnRenamed("f", "h").select("h"), Row(Row(12)))
        checkAnswer(df.withColumnRenamed("f", "f").select("f"), Row(Row(12)))
        checkAnswer(df.withColumnRenamed("`a.b`", "s").select("s"), Row(10))
        checkAnswer(df.withColumnRenamed("f", "h").select("`a.b`"), Row(10))
    ```



---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to