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_r300891962
##########
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:
- First, it's not a correct(?) use-case to switch the case sensitivity
between declaring the variable and using the variable.
- Second, I merged this to `master` only with the similar concern. :)
Since this is a bug fix, I think we don't need a documentation about this.
And, 3.0.0 is a good place to change those behavior change due to the bug fix.
----------------------------------------------------------------
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]