You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by gatorsmile <gi...@git.apache.org> on 2017/01/28 08:54:18 UTC
[GitHub] spark pull request #15797: [SPARK-17990][SPARK-18302][SQL] correct several p...
Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/15797#discussion_r98327471
--- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala ---
@@ -810,13 +825,43 @@ private[spark] class HiveExternalCatalog(conf: SparkConf, hadoopConf: Configurat
newSpecs: Seq[TablePartitionSpec]): Unit = withClient {
client.renamePartitions(
db, table, specs.map(lowerCasePartitionSpec), newSpecs.map(lowerCasePartitionSpec))
+
+ val tableMeta = getTable(db, table)
+ val partitionColumnNames = tableMeta.partitionColumnNames
+ // Hive metastore is not case preserving and keeps partition columns with lower cased names.
+ // When Hive rename partition for managed tables, it will create the partition location with
+ // a default path generate by the new spec with lower cased partition column names. This is
+ // unexpected and we need to rename them manually and alter the partition location.
+ val hasUpperCasePartitionColumn = partitionColumnNames.exists(col => col.toLowerCase != col)
+ if (tableMeta.tableType == MANAGED && hasUpperCasePartitionColumn) {
+ val tablePath = new Path(tableMeta.location)
+ val newParts = newSpecs.map { spec =>
+ val partition = client.getPartition(db, table, lowerCasePartitionSpec(spec))
+ val wrongPath = new Path(partition.location)
+ val rightPath = ExternalCatalogUtils.generatePartitionPath(
+ spec, partitionColumnNames, tablePath)
+ try {
+ tablePath.getFileSystem(hadoopConf).rename(wrongPath, rightPath)
--- End diff --
Found an issue here... When we call `rename`, not all the file systems have the same behaviors. For example, on mac OS, when we doing this `.../tbl/partcol1=5/partcol2=6` -> `.../tbl/partCol1=5/partCol2=6` . The result is `.../tbl/partcol1=5/partCol2=6`. However, the file system used in Jenkin does not have such an issue.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org