From 3ced39df32e52170d6954a2464f84e0c9f307423 Mon Sep 17 00:00:00 2001 From: Wenchen Fan Date: Thu, 8 Sep 2016 19:41:49 +0800 Subject: [SPARK-17432][SQL] PreprocessDDL should respect case sensitivity when checking duplicated columns ## What changes were proposed in this pull request? In `PreprocessDDL` we will check if table columns are duplicated. However, this checking ignores case sensitivity config(it's always case-sensitive) and lead to different result between `HiveExternalCatalog` and `InMemoryCatalog`. `HiveExternalCatalog` will throw exception because hive metastore is always case-nonsensitive, and `InMemoryCatalog` is fine. This PR fixes it. ## How was this patch tested? a new test in DDLSuite Author: Wenchen Fan Closes #14994 from cloud-fan/check-dup. --- .../scala/org/apache/spark/sql/execution/command/DDLSuite.scala | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sql/core/src/test/scala') diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala index fd35c987ca..05f826a11b 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala @@ -371,6 +371,13 @@ class DDLSuite extends QueryTest with SharedSQLContext with BeforeAndAfterEach { sql("CREATE TABLE tbl(a int, a string) USING json") } assert(e.message == "Found duplicate column(s) in table definition of `tbl`: a") + + withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") { + val e2 = intercept[AnalysisException] { + sql("CREATE TABLE tbl(a int, A string) USING json") + } + assert(e2.message == "Found duplicate column(s) in table definition of `tbl`: a") + } } test("create table - partition column names not in table definition") { -- cgit v1.2.3