wecharyu commented on code in PR #5539: URL: https://github.com/apache/hive/pull/5539#discussion_r1900184832
########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/client/builder/GetPartitionProjectionsSpecBuilder.java: ########## @@ -41,6 +42,12 @@ public GetPartitionProjectionsSpecBuilder addProjectField(String field) { return this; } + public GetPartitionProjectionsSpecBuilder addProjectFieldList(List<String> fields) { + fieldList.addAll(Arrays.asList("catName","dbName","tableName")); Review Comment: These fields would be added repeatedly here. If they are necessary, could we initiate `fieldList` with them instead? ########## ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java: ########## @@ -4086,6 +4091,37 @@ public List<String> getPartitionNames(String dbName, String tblName, return names; } + // get partition names from provided partition values + public List<String> getPartitionNames(String dbName, String tblName, + short max, List<String> pVals) throws HiveException { + List<String> names = null; + Table t = getTable(dbName, tblName); + + try { + GetPartitionNamesPsRequest req = new GetPartitionNamesPsRequest(); + req.setTblName(tblName); + req.setDbName(dbName); + req.setPartValues(pVals); + req.setMaxParts(max); + if (AcidUtils.isTransactionalTable(t)) { + ValidWriteIdList validWriteIdList = getValidWriteIdList(dbName, tblName); + req.setValidWriteIdList(validWriteIdList != null ? validWriteIdList.toString() : null); + req.setId(t.getTTable().getId()); + } + GetPartitionNamesPsResponse res = getMSC().listPartitionNamesRequest(req); + names = res.getNames(); + } catch (NoSuchObjectException nsoe) { + // this means no partition exists for the given partition spec + // key value pairs - thrift cannot handle null return values, hence + // listPartitionNames() throws NoSuchObjectException to indicate null partitions + return Lists.newArrayList(); Review Comment: I think we should wrap and throw an exception for `NoSuchObjectException`, as returning an empty result can be ambiguous. -- 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