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 @@ -29,6 +29,7 @@ import org.apache.spark.sql.{AnalysisException, Row, SparkSession}
import org.apache.spark.sql.catalyst.catalog._
import org.apache.spark.sql.catalyst.expressions.Attribute
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
import org.apache.spark.sql.catalyst.util.CaseInsensitiveMap
import org.apache.spark.sql.execution.SparkPlan
import org.apache.spark.sql.execution.command.CommandUtils
import org.apache.spark.sql.hive.HiveExternalCatalog
Expand Down Expand Up @@ -225,9 +226,12 @@ case class InsertIntoHiveTable(
ExternalCatalogUtils.unescapePathName(splitPart(1))
}.toMap

val caseInsensitiveDpMap = CaseInsensitiveMap(dpMap)

val updatedPartitionSpec = partition.map {
case (key, Some(value)) => key -> value
case (key, None) if dpMap.contains(key) => key -> dpMap(key)
case (key, None) if caseInsensitiveDpMap.contains(key) =>
key -> caseInsensitiveDpMap(key)
case (key, _) =>
throw new SparkException(s"Dynamic partition key $key is not among " +
"written partition paths.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2544,6 +2544,19 @@ abstract class SQLQuerySuiteBase extends QueryTest with SQLTestUtils with TestHi
assert(e.getMessage.contains("Cannot modify the value of a static config"))
}
}

test("SPARK-29295: dynamic partition map parsed from partition path should be case insensitive") {
withTable("t") {
withSQLConf("hive.exec.dynamic.partition" -> "true",
"hive.exec.dynamic.partition.mode" -> "nonstrict") {
withTempDir { loc =>
sql(s"CREATE TABLE t(c1 INT) PARTITIONED BY(P1 STRING) LOCATION '${loc.getAbsolutePath}'")
sql("INSERT OVERWRITE TABLE t PARTITION(P1) VALUES(1, 'caseSensitive')")
checkAnswer(sql("select * from t"), Row(1, "caseSensitive"))
}
}
}
}
}

class SQLQuerySuite extends SQLQuerySuiteBase with DisableAdaptiveExecutionSuite
Expand Down