Github user gatorsmile commented on a diff in the pull request: https://github.com/apache/spark/pull/18356#discussion_r123157059 --- Diff: sql/core/src/test/scala/org/apache/spark/sql/test/DataFrameReaderWriterSuite.scala --- @@ -678,4 +679,34 @@ class DataFrameReaderWriterSuite extends QueryTest with SharedSQLContext with Be assert(e.contains("User specified schema not supported with `table`")) } } + + test("SPARK-21144 fails when data schema and partition schema have duplicate columns") { + // Check CSV format + Seq((true, ("a", "a")), (false, ("aA", "Aa"))).foreach { case (caseSensitive, (c0, c1)) => + withSQLConf(SQLConf.CASE_SENSITIVE.key -> caseSensitive.toString) { + withTempDir { src => + Seq(1).toDF(c0).write.option("header", true).mode("overwrite").csv(s"$src/$c1=1") + val e = intercept[AnalysisException] { + spark.read.option("header", true).csv(src.toString) + } + assert(e.getMessage.contains("Found duplicate column(s) in the datasource: ")) + } + } + } + + // Check JSON/Parquet format + Seq("json", "parquet").foreach { case format => + Seq((true, ("a", "a")), (false, ("aA", "Aa"))).foreach { case (caseSensitive, (c0, c1)) => + withSQLConf(SQLConf.CASE_SENSITIVE.key -> caseSensitive.toString) { + withTempDir { src => + Seq(1).toDF(c0).write.format(format).mode("overwrite").save(s"$src/$c1=1") + val e = intercept[AnalysisException] { + spark.read.format(format).load(src.toString) + } + assert(e.getMessage.contains("Found duplicate column(s) in the datasource: ")) --- End diff -- BTW, could you also add another test case? Even if there exists duplicate columns between data schema and partition schema, users still can query the data by manually specifying the schema?
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org