Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15024#discussion_r79212283
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala ---
    @@ -409,16 +416,30 @@ private[spark] class HiveExternalCatalog(conf: 
SparkConf, hadoopConf: Configurat
         }
     
         if (DDLUtils.isDatasourceTable(withStatsProps)) {
    -      val oldDef = client.getTable(db, withStatsProps.identifier.table)
    -      // Sets the `schema`, `partitionColumnNames` and `bucketSpec` from 
the old table definition,
    -      // to retain the spark specific format if it is. Also add old data 
source properties to table
    -      // properties, to retain the data source table format.
    -      val oldDataSourceProps = 
oldDef.properties.filter(_._1.startsWith(DATASOURCE_PREFIX))
    +      val oldTableDef = client.getTable(db, 
withStatsProps.identifier.table)
    +
    +      val oldLocation = getLocationFromRawTable(oldTableDef)
    +      // Only update the `locationUri` field if the location is really 
changed.
    +      val newLocation = if (oldLocation == 
tableDefinition.storage.locationUri) {
    --- End diff --
    
    This is to keep the previous behaviour.
    
    Previously, if we alter table fields (exclude location), we will keep the 
`locationUri` field and `path` option unchanged. If we alter table location, we 
will update both the `locationUri` field and `path` option, although it's 
dangerous to set `locationUri` as the path may be a file path.
    
    Now, if we alter table fields (exclude location), we will keep the 
`locationUri` field unchanged, although the `locationUri` field may be 
different from the one in old raw table(the `oldTableDef` get from hive client 
directly) due to the hacks in `saveTableIntoHive`. If we alter table location, 
we will update the `locationUri` field even it's file path, which is the same 
behaviour as before.



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