cloud-fan commented on a change in pull request #31854: URL: https://github.com/apache/spark/pull/31854#discussion_r600185552
########## File path: sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala ########## @@ -2738,6 +2738,31 @@ class DataFrameSuite extends QueryTest checkAnswer(df.select(col2), Row(1) :: Row(2) :: Row(3) :: Nil) } + test("SPARK-34763: col(), $\"<name>\", df(\"name\") should handle quoted column name properly") { + val df1 = spark.sql("SELECT 'col1' AS `a``b.c`") + checkAnswer(df1.selectExpr("`a``b.c`"), Row("col1")) + checkAnswer(df1.select(df1("`a``b.c`")), Row("col1")) + checkAnswer(df1.select(col("`a``b.c`")), Row("col1")) + checkAnswer(df1.select($"`a``b.c`"), Row("col1")) + + val df2 = df1.as("d.e`f") + checkAnswer(df2.selectExpr("`a``b.c`"), Row("col1")) + checkAnswer(df2.select(df2("`a``b.c`")), Row("col1")) + checkAnswer(df2.select(col("`a``b.c`")), Row("col1")) + checkAnswer(df2.select($"`a``b.c`"), Row("col1")) + + checkAnswer(df2.selectExpr("`d.e``f`.`a``b.c`"), Row("col1")) + checkAnswer(df2.select(df2("`d.e``f`.`a``b.c`")), Row("col1")) + checkAnswer(df2.select(col("`d.e``f`.`a``b.c`")), Row("col1")) + checkAnswer(df2.select($"`d.e``f`.`a``b.c`"), Row("col1")) + + val df3 = df1.as("*-#&% ?") + checkAnswer(df3.selectExpr("`*-#&% ?`.`a``b.c`"), Row("col1")) + checkAnswer(df3.select(df3("*-#&% ?.`a``b.c`")), Row("col1")) + checkAnswer(df3.select(col("*-#&% ?.`a``b.c`")), Row("col1")) + checkAnswer(df3.select($"*-#&% ?.`a``b.c`"), Row("col1")) Review comment: If 40+ tests fail, we definitely shouldn't do it in this PR. It's intentional when we write the code, but I don't think it's intentional to allow end-users to do something like `df3.select($"*-#&% ?.`a``b.c`")`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org