Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/8811#discussion_r39988465
--- 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 --
For these tests, which ones will fail without your fix?
---
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]