Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16837#discussion_r100174684
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala ---
    @@ -892,21 +892,58 @@ private[spark] class HiveExternalCatalog(conf: 
SparkConf, hadoopConf: Configurat
         val hasUpperCasePartitionColumn = partitionColumnNames.exists(col => 
col.toLowerCase != col)
         if (tableMeta.tableType == MANAGED && hasUpperCasePartitionColumn) {
           val tablePath = new Path(tableMeta.location)
    +      val fs = tablePath.getFileSystem(hadoopConf)
           val newParts = newSpecs.map { spec =>
    +        val rightPath = renamePartitionDirectory(fs, tablePath, 
partitionColumnNames, spec)
             val partition = client.getPartition(db, table, 
lowerCasePartitionSpec(spec))
    -        val wrongPath = new Path(partition.location)
    -        val rightPath = ExternalCatalogUtils.generatePartitionPath(
    -          spec, partitionColumnNames, tablePath)
    +        partition.copy(storage = partition.storage.copy(locationUri = 
Some(rightPath.toString)))
    +      }
    +      alterPartitions(db, table, newParts)
    +    }
    +  }
    +
    +  /**
    +   * Rename the partition directory w.r.t. the actual partition columns.
    +   *
    +   * It will recursively rename the partition directory from the first 
partition column, to be most
    +   * compatible with different file systems. e.g. in some file systems, 
renaming `a=1/b=2` to
    +   * `A=1/B=2` will result to `a=1/B=2`, while in some other file systems, 
the renaming works, but
    +   * will leave an empty directory `a=1`.
    +   */
    +  private def renamePartitionDirectory(
    +      fs: FileSystem,
    +      tablePath: Path,
    +      partCols: Seq[String],
    +      newSpec: TablePartitionSpec): Path = {
    +    import ExternalCatalogUtils.getPartitionPathString
    +
    +    var totalPath = tablePath
    --- End diff --
    
    How about `currFullPath` or `fullPath`?


---
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

Reply via email to