deniskuzZ commented on code in PR #5063: URL: https://github.com/apache/hive/pull/5063#discussion_r1525998481
########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java: ########## @@ -1023,33 +1023,43 @@ public <T> List<T> getPartitionFieldsViaSqlFilter( /** Should be called with the list short enough to not trip up Oracle/etc. */ - private List<Partition> getPartitionsFromPartitionNames(String catName, String dbName, + private List<Partition> getPartitionsByNames(String catName, String dbName, String tblName, Boolean isView, List<String> partNameList, List<String> projectionFields, boolean isAcidTable, GetPartitionsArgs args) throws MetaException { // Get most of the fields for the partNames provided. // Assume db and table names are the same for all partition, as provided in arguments. - String partNames = partNameList.stream() - .map(name -> "'" + name + "'") - .collect(Collectors.joining(",")); - String queryText = - "select " + PARTITIONS + ".\"PART_ID\", " + SDS + ".\"SD_ID\", " + SDS + ".\"CD_ID\"," + " " - + SERDES + ".\"SERDE_ID\", " + PARTITIONS + ".\"CREATE_TIME\"," + " " + PARTITIONS - + ".\"LAST_ACCESS_TIME\", " + SDS + ".\"INPUT_FORMAT\", " + SDS + ".\"IS_COMPRESSED\"," - + " " + SDS + ".\"IS_STOREDASSUBDIRECTORIES\", " + SDS + ".\"LOCATION\", " + SDS - + ".\"NUM_BUCKETS\"," + " " + SDS + ".\"OUTPUT_FORMAT\", " + SERDES + ".\"NAME\", " - + SERDES + ".\"SLIB\", " + PARTITIONS + ".\"WRITE_ID\"" + " from " + PARTITIONS + "" - + " left outer join " + SDS + " on " + PARTITIONS + ".\"SD_ID\" = " + SDS - + ".\"SD_ID\" " + " left outer join " + SERDES + " on " + SDS + ".\"SERDE_ID\" = " - + SERDES + ".\"SERDE_ID\" " + " inner join " + TBLS + " on " + TBLS + ".\"TBL_ID\" = " - + PARTITIONS + ".\"TBL_ID\" " + " inner join " + DBS + " on " + DBS + ".\"DB_ID\" = " - + TBLS + ".\"DB_ID\" " + "where \"PART_NAME\" in (" + partNames + ") " - + " and " + TBLS + ".\"TBL_NAME\" = ? and " + DBS + ".\"NAME\" = ? and " + DBS - + ".\"CTLG_NAME\" = ? order by \"PART_NAME\" asc"; + List<String> queries = new ArrayList<>(); + StringBuilder prefix = new StringBuilder(); + StringBuilder suffix = new StringBuilder(); + + List<String> quotedPartNames = partNameList.stream() + .map(DirectSqlUpdatePart::quoteString) + .collect(Collectors.toList()); + + prefix.append( + "select " + PARTITIONS + ".\"PART_ID\"," + SDS + ".\"SD_ID\"," + SDS + ".\"CD_ID\"," + + SERDES + ".\"SERDE_ID\"," + PARTITIONS + ".\"CREATE_TIME\"," + PARTITIONS + + ".\"LAST_ACCESS_TIME\"," + SDS + ".\"INPUT_FORMAT\"," + SDS + ".\"IS_COMPRESSED\"," + + SDS + ".\"IS_STOREDASSUBDIRECTORIES\"," + SDS + ".\"LOCATION\"," + SDS + + ".\"NUM_BUCKETS\"," + SDS + ".\"OUTPUT_FORMAT\"," + SERDES + ".\"NAME\"," + + SERDES + ".\"SLIB\"," + PARTITIONS + ".\"WRITE_ID\"" + " from " + PARTITIONS + + " left outer join " + SDS + " on " + PARTITIONS + ".\"SD_ID\" = " + SDS + ".\"SD_ID\" " + + " left outer join " + SERDES + " on " + SDS + ".\"SERDE_ID\" = " + SERDES + ".\"SERDE_ID\" " + + " inner join " + TBLS + " on " + TBLS + ".\"TBL_ID\" = " + PARTITIONS + ".\"TBL_ID\" " + + " inner join " + DBS + " on " + DBS + ".\"DB_ID\" = " + TBLS + ".\"DB_ID\" where "); + suffix.append( + " and " + TBLS + ".\"TBL_NAME\" = ? and " + DBS + ".\"NAME\" = ? and " + DBS + + ".\"CTLG_NAME\" = ? order by \"PART_NAME\" asc"); + + TxnUtils.buildQueryWithINClauseStrings(conf, queries, prefix, suffix, quotedPartNames, Review Comment: sorry, I didn't notice that it's already under `Batchable.runBatched`. Not sure we want to use `TxnUtils.buildQueryWithINClauseStrings` here as it's used to construct mini-batches as well. Simple `IN` should be sufficient: ```` String quotedPartNames = partNameList.stream() .map(DirectSqlUpdatePart::quoteString) .collect(Collectors.joining(",")); "where \"PART_NAME\" IN (" + quotedPartNames + ") " ```` -- 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