Github user dongjoon-hyun commented on a diff in the pull request: https://github.com/apache/spark/pull/18356#discussion_r123082436 --- Diff: sql/core/src/test/scala/org/apache/spark/sql/test/DataFrameReaderWriterSuite.scala --- @@ -678,4 +679,45 @@ 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 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.mode("overwrite").json(s"$src/$c1=1") --- End diff -- For `spark.read.json`, ``` spark.read.format('..').load ```
--- 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