veghlaci05 commented on code in PR #3557: URL: https://github.com/apache/hive/pull/3557#discussion_r973924216
########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java: ########## @@ -226,16 +229,21 @@ private static ColumnStatistics updateStatsForAlterPart(RawStore rawStore, Table private static void updateStatsForAlterTable(RawStore rawStore, Table tblBefore, Table tblAfter, String catalogName, String dbName, String tableName) throws Exception { ColumnStatistics colStats = null; - List<String> deletedCols = new ArrayList<>(); if (tblBefore.isSetPartitionKeys()) { List<Partition> parts = sharedCache.listCachedPartitions(catalogName, dbName, tableName, -1); for (Partition part : parts) { colStats = updateStatsForAlterPart(rawStore, tblBefore, catalogName, dbName, tableName, part); } } - List<ColumnStatistics> multiColumnStats = HiveAlterHandler - .alterTableUpdateTableColumnStats(rawStore, tblBefore, tblAfter, null, null, rawStore.getConf(), deletedCols); + rawStore.alterTable(catalogName, dbName, tblBefore.getTableName(), tblAfter, null); + + Set<String> deletedCols = new HashSet<>(); + List<ColumnStatistics> multiColumnStats = HiveAlterHandler.getColumnStats(rawStore, tblBefore); + multiColumnStats.forEach(cs -> + deletedCols.addAll(HiveAlterHandler.filterColumnStatsForTableColumns(tblBefore.getSd().getCols(), cs) Review Comment: The `deletedCols.addAll()` call is inside a foreach, so simple assignment is not possible. And yes, it was part of the `alterTableUpdateTableColumnStats`. There was a kind of "dry run" mode in which no changes were made, only the deletedColumns list was filled. I found that approach a bit clunky, as it made the code hard to read by adding a lot of extra if-else statements. So I decided to extract the filtering logic into a separate method which can be called both from here and from `HiveAlterHandler` -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org