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

    https://github.com/apache/spark/pull/15024#discussion_r86070624
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala ---
    @@ -383,8 +389,22 @@ private[spark] class HiveExternalCatalog(conf: 
SparkConf, hadoopConf: Configurat
       }
     
       override def renameTable(db: String, oldName: String, newName: String): 
Unit = withClient {
    -    val newTable = client.getTable(db, oldName)
    -      .copy(identifier = TableIdentifier(newName, Some(db)))
    +    val rawTable = client.getTable(db, oldName)
    +
    +    val tableProps = if (rawTable.tableType == MANAGED) {
    +      // If it's a managed table and we are renaming it, then the 
TABLE_LOCATION property becomes
    +      // inaccurate as Hive metastore will generate a new table location 
in the `locationUri` field.
    +      // Here we remove the TABLE_LOCATION property, so that we can read 
the value of `locationUri`
    +      // field and treat it as table location when we read this table 
later.
    +      rawTable.properties - TABLE_LOCATION
    +    } else {
    +      rawTable.properties
    +    }
    +
    +    val newTable = rawTable.copy(
    +      identifier = TableIdentifier(newName, Some(db)),
    +      properties = tableProps)
    +
    --- End diff --
    
    I am not sure if I am following at here. So, after rename, we will not have 
a table property representing the location?


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