Github user yhuai commented on a diff in the pull request: https://github.com/apache/spark/pull/14750#discussion_r86471149 --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala --- @@ -475,18 +490,27 @@ private[spark] class HiveExternalCatalog(conf: SparkConf, hadoopConf: Configurat tableDefinition } - if (DDLUtils.isDatasourceTable(withStatsProps)) { - val oldTableDef = client.getTable(db, withStatsProps.identifier.table) + if (tableDefinition.tableType == VIEW) { + client.alterTable(withStatsProps) + } else { + val oldTableDef = getRawTable(db, withStatsProps.identifier.table) - val oldLocation = getLocationFromStorageProps(oldTableDef) - val newLocation = tableDefinition.storage.locationUri - // Only update the `locationUri` field if the location is really changed, because this table - // may be not Hive-compatible and can not set the `locationUri` field. We should respect the - // old `locationUri` even it's None. - val storageWithNewLocation = if (oldLocation == newLocation) { - oldTableDef.storage + val newStorage = if (tableDefinition.provider.get == "hive") { + tableDefinition.storage } else { - updateLocationInStorageProps(oldTableDef, newLocation).copy(locationUri = newLocation) + val newLocation = tableDefinition.storage.locationUri + val storageWithPathOption = tableDefinition.storage.copy( + properties = tableDefinition.storage.properties ++ newLocation.map("path" -> _)) + + // For data source tables, only update the `locationUri` field if the location is really + // changed, because this table may be not Hive-compatible and can not set the `locationUri` + // field. We should respect the old `locationUri` even it's None. + val oldLocation = getLocationFromStorageProps(oldTableDef) + if (oldLocation == newLocation) { + storageWithPathOption.copy(locationUri = oldTableDef.storage.locationUri) --- End diff -- Let's use an example to explain what we are doing at here.
--- 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