okumin commented on code in PR #5883:
URL: https://github.com/apache/hive/pull/5883#discussion_r2160233745
##########
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 ( "
Review Comment:
I prefer `SELECT DISTINCT` for readability. But performance might rely on
RDBMS.
##########
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) {
+ for (Object cdId : sqlResult) {
+ cdIds.add(MetastoreDirectSqlUtils.extractSqlLong(cdId));
Review Comment:
Is it necessary to use `extractSqlLong`? If not, we may have a
shorthand(with a bit more efficient ArrayList initialization, which is very
tiny).
```sql
List<Long> sqlResult = executeWithArray(query.getInnerQuery(), null,
queryText);
return sqlResult != null ? new ArrayList<>(sqlResult) :
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]