Github user cloud-fan commented on a diff in the pull request:
    --- 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 =
    +      val oldTableDef = client.getTable(db, 
    +      val oldLocation = getLocationFromRawTable(oldTableDef)
    +      // Only update the `locationUri` field if the location is really 
    +      val newLocation = if (oldLocation == {
    --- 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 or file a JIRA ticket
with INFRA.

To unsubscribe, e-mail:
For additional commands, e-mail:

Reply via email to