deniskuzZ commented on code in PR #5539: URL: https://github.com/apache/hive/pull/5539#discussion_r1901769308
########## ql/src/java/org/apache/hadoop/hive/ql/metadata/PartitionTree.java: ########## @@ -271,4 +277,69 @@ List<Partition> getPartitionsByFilter(final String filter) throws MetaException } return result; } + + GetPartitionsResponse getPartitionsWithSpecs(GetPartitionsRequest getPartitionsRequest) throws MetaException { + List<Partition> result = new ArrayList<>(); + PartitionListComposingSpec partListComp; + + PartitionSpec partitionSpec = new PartitionSpec(); + partitionSpec.setCatName(getPartitionsRequest.getCatName()); + partitionSpec.setDbName(getPartitionsRequest.getDbName()); + partitionSpec.setTableName(getPartitionsRequest.getTblName()); + + List<PartitionSpec> partSpecs; + + GetPartitionsFilterSpec filterSpec = getPartitionsRequest.getFilterSpec(); + if (filterSpec == null) { + partListComp = new PartitionListComposingSpec(new ArrayList<>(parts.values())); + partitionSpec.setPartitionList(partListComp); + + partSpecs = Arrays.asList(partitionSpec); + return new GetPartitionsResponse(partSpecs); + } + + for (Map.Entry<String, Partition> entry : parts.entrySet()) { + Partition partition = entry.getValue(); + boolean matches = false; + + PartitionFilterMode filterMode = filterSpec.getFilterMode(); + switch (filterMode) { + case BY_NAMES: + matches = filterSpec.getFilters().contains(entry.getKey()); + break; + case BY_VALUES: + matches = filterSpec.getFilters().contains(entry.getValue()); + break; + case BY_EXPR: + ScriptEngine se = new ScriptEngineManager().getEngineByName("JavaScript"); + if (se == null) { + LOG.error("JavaScript script engine is not found, therefore partition filtering " + + "for temporary tables is disabled."); + break; + } + + for (String filter : filterSpec.getFilters()) { + try { + se.put("partition", partition); + matches = (Boolean) se.eval(filter); + if (!matches) break; Review Comment: seems unnnesesary -- 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