dongjoon-hyun commented on a change in pull request #25055: [SPARK-28189][SQL]
Use semanticEquals in Dataset drop method for attributes comparison
URL: https://github.com/apache/spark/pull/25055#discussion_r300892068
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala
##########
@@ -572,6 +572,29 @@ class DataFrameSuite extends QueryTest with
SharedSQLContext {
assert(df.schema.map(_.name) === Seq("value"))
}
+ test("SPARK-28189 drop column using drop with column reference with
case-insensitive names") {
+ // With SQL config caseSensitive OFF, case insensitive column name should
work
+ withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") {
+ val col1 = testData("KEY")
+ val df1 = testData.drop(col1)
+ checkAnswer(df1, testData.selectExpr("value"))
+ assert(df1.schema.map(_.name) === Seq("value"))
+
+ val col2 = testData("Key")
+ val df2 = testData.drop(col2)
+ checkAnswer(df2, testData.selectExpr("value"))
+ assert(df2.schema.map(_.name) === Seq("value"))
+ }
+
+ // With SQL config caseSensitive ON, AnalysisException should be thrown
+ withSQLConf(SQLConf.CASE_SENSITIVE.key -> "true") {
+ val e = intercept[AnalysisException] {
+ testData("KEY")
Review comment:
Do you have any suggestion for your concern? Then, please share it with us~
You're welcome.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]