dengzhhu653 commented on code in PR #5883: URL: https://github.com/apache/hive/pull/5883#discussion_r2160214986
########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java: ########## @@ -892,18 +892,25 @@ public List<Void> run(List<Long> input) throws Exception { sdIdToNewCdId.containsKey(sdId) ? sdIdToNewCdId.get(sdId) : cdId); updateSDInBatch(validSdIds, idToSd, sdIdToCdId); - List<Long> usedIds = Batchable.runBatched(maxBatchSize, cdIdsMayDelete, + Set<Long> usedIds = new HashSet<>(Batchable.runBatched(maxBatchSize, cdIdsMayDelete, new Batchable<Long, Long>() { @Override public List<Long> run(List<Long> input) throws Exception { String idLists = MetaStoreDirectSql.getIdListForIn(input); - String queryText = "select \"CD_ID\" from \"SDS\" where \"CD_ID\" in ( " + idLists + ")"; + String queryText = "select \"CD_ID\" from \"SDS\" where \"CD_ID\" in ( " + + idLists + ") group by \"CD_ID\""; + List<Long> cdIds = new ArrayList<>(); try (QueryWrapper query = new QueryWrapper(pm.newQuery("javax.jdo.query.SQL", queryText))) { - List<Long> sqlResult = executeWithArray(query.getInnerQuery(), null, queryText); - return new ArrayList<>(sqlResult); + List<Object> sqlResult = executeWithArray(query.getInnerQuery(), null, queryText); + if (sqlResult != null) { Review Comment: Add the null check just in case, as this `sqlResult` is from calling the dependent lib. > Can we move cdIds initialization here? I don't want the `Batchable.runBatched` return a null list, which might be pushed to create a new `HashSet`, nor two `return` lines, one for `cdIds`, the other `Collections.emptyList()` -- 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