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

    https://github.com/apache/spark/pull/15797#discussion_r87336535
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala ---
    @@ -810,13 +825,44 @@ 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 fs = tablePath.getFileSystem(hadoopConf)
    --- End diff --
    
    [In the other 
functions](https://github.com/cloud-fan/spark/blob/56f3073162f0b53e4a3de686bba31c8eb6048123/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalog.scala#L367-L371),
 the function call `getFileSystem` is also part of the try-catch block. Do we 
need to make it consistent with others?


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to