Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,11 @@ class AstBuilder(conf: SQLConf) extends SqlBaseBaseVisitor[AnyRef] with Logging
// Before calling `toMap`, we check duplicated keys to avoid silently ignore partition values
// in partition spec like PARTITION(a='1', b='2', a='3'). The real semantical check for
// partition columns will be done in analyzer.
checkDuplicateKeys(parts, ctx)
if (conf.caseSensitiveAnalysis) {
checkDuplicateKeys(parts, ctx)
} else {
checkDuplicateKeys(parts.map(kv => kv._1.toLowerCase(Locale.ROOT) -> kv._2), ctx)
}
parts.toMap
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,17 @@ class DDLParserSuite extends AnalysisTest with SharedSparkSession {
assert(e.contains("Found duplicate keys 'key1'"))
}

test("SPARK-34556: duplicate keys in partition spec") {
val e = intercept[ParseException] {
parser.parsePlan("INSERT OVERWRITE t PARTITION (c='2', C='3') VALUES (1)")
}.getMessage
assert(e.contains("Found duplicate keys 'c'"))
val conf = new SQLConf()
conf.setConf(SQLConf.CASE_SENSITIVE, true)
val caseSensitiveParser = new SparkSqlParser(conf)
caseSensitiveParser.parsePlan("INSERT OVERWRITE t PARTITION (c='2', C='3') VALUES (1)")
}

test("duplicate columns in partition specs") {
val e = intercept[ParseException] {
parser.parsePlan(
Expand Down