diqiu50 commented on code in PR #13021:
URL: https://github.com/apache/gravitino/pull/13021#discussion_r3965170493
##########
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());
Review Comment:
Change the call function of alterTable in TestHive2HMS/TestHive3HMS to
cover this logic
##########
catalogs/hive-metastore-common/src/main/java/org/apache/gravitino/hive/client/HiveShimV2.java:
##########
@@ -294,4 +309,18 @@ public void createCatalog(String catalogName, String
location, String descriptio
public void close() throws Exception {
client.close();
}
+
+ /**
+ * Builds an {@link EnvironmentContext} that tells the metastore not to
recompute table statistics
+ * during an alter, avoiding an access to the table's storage location.
+ *
+ * @return An environment context with {@code DO_NOT_UPDATE_STATS} set to
{@code true}.
+ */
+ protected EnvironmentContext doNotUpdateStatsContext() {
+ // Use the literal "true" rather than StatsSetupConst.TRUE, which is not
present in all
+ // supported
+ // Hive versions (e.g. Hive 3.1.3).
Review Comment:
Verify the description and formatting of this comment.
--
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]