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

    https://github.com/apache/spark/pull/15024#discussion_r78475247
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala ---
    @@ -410,15 +417,22 @@ 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))
    +      // get the data source properties from old table definition, and add 
the new location entry.
    +      val dataSourceProps = 
oldDef.properties.filter(_._1.startsWith(DATASOURCE_PREFIX)) ++
    +        tableDefinition.storage.locationUri.map { location =>
    +          DATASOURCE_LOCATION -> location
    +        }
           val newDef = withStatsProps.copy(
    +        // TODO: we may break the hive-compatibility format for location 
URI here, we should follow
    +        // `createTable` and try to alter the table with `locationUri` 
set, if it's failed, then set
    --- End diff --
    
    However, Hive normally does not return exceptions immediately. After 
incorrectly altering the table, we could get an exception when reading/writing 
this table. For example, we set the `locationUri` to `None` for a Hive managed 
table. We will hit an error when inserting the data into this table. When we 
drop the Hive-managed table, Hive should delete the directory pointed by 
`locationUri`. Then, if it is `None`, the directory will not be dropped.


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