geyanggang commented on code in PR #13021:
URL: https://github.com/apache/gravitino/pull/13021#discussion_r3965391175


##########
catalogs/hive-metastore-common/src/main/java/org/apache/gravitino/hive/client/HiveShimV2.java:
##########
@@ -148,10 +151,22 @@ public HiveTable getTable(String catalogName, String 
databaseName, String tableN
 
   @Override
   public void alterTable(
-      String catalogName, String databaseName, String tableName, HiveTable 
alteredHiveTable) {
+      String catalogName,
+      String databaseName,
+      String tableName,
+      HiveTable alteredHiveTable,
+      boolean skipStatsUpdate) {
     try {
       var tb = HiveTableConverter.toHiveTable(alteredHiveTable);
-      client.alter_table(databaseName, tableName, tb);
+      if (skipStatsUpdate) {
+        // Instruct the metastore not to recompute statistics for this alter, 
so it does not access
+        // the table's storage location. Hive 2.x has no catalog-aware alter, 
so the database name
+        // is used directly.
+        client.alter_table_with_environmentContext(
+            databaseName, tableName, tb, doNotUpdateStatsContext());
+      } else {
+        client.alter_table(databaseName, tableName, tb);
+      }

Review Comment:
   Added TestHiveShimAlterTable in hive-metastore-common: it mocks 
IMetaStoreClient and verifies that skipStatsUpdate=true invokes 
alter_table_with_environmentContext with an EnvironmentContext where 
DO_NOT_UPDATE_STATS="true", and that the default path uses the plain 
alter_table. Note the Hive3 catalog-aware alter_table(..., EnvironmentContext) 
overload only exists in the Hive 3 API and can't be referenced from this test 
module (compiled against Hive 2 API), so its invocation is covered by the 
Docker-based TestHive3HMS.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to