deniskuzZ commented on code in PR #4785: URL: https://github.com/apache/hive/pull/4785#discussion_r1381665986
########## iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandler.java: ########## @@ -1932,4 +1938,49 @@ public boolean canPerformMetadataDelete(org.apache.hadoop.hive.ql.metadata.Table return false; } } + + @Override + public List<FieldSchema> getPartitionKeys(org.apache.hadoop.hive.ql.metadata.Table hmsTable) { + Table icebergTable = IcebergTableUtil.getTable(conf, hmsTable.getTTable()); + Schema schema = icebergTable.schema(); + List<FieldSchema> hiveSchema = HiveSchemaUtil.convert(schema); + Map<String, String> colNameToColType = hiveSchema.stream() + .collect(Collectors.toMap(FieldSchema::getName, FieldSchema::getType)); + return icebergTable.spec().fields().stream().map(partField -> + new FieldSchema(schema.findColumnName(partField.sourceId()), + colNameToColType.get(schema.findColumnName(partField.sourceId())), + String.format("Transform: %s", partField.transform().toString()))).collect(Collectors.toList()); + } + + @Override + public List<Partition> getPartitionsByExpr(org.apache.hadoop.hive.ql.metadata.Table hmsTable, ExprNodeDesc desc) + throws SemanticException { + Table icebergTable = IcebergTableUtil.getTable(conf, hmsTable.getTTable()); + PartitionSpec pSpec = icebergTable.spec(); + PartitionsTable partitionsTable = (PartitionsTable) MetadataTableUtils + .createMetadataTableInstance(icebergTable, MetadataTableType.PARTITIONS); + SearchArgument sarg = ConvertAstToSearchArg.create(conf, (ExprNodeGenericFuncDesc) desc); + Expression expression = HiveIcebergFilterFactory.generateFilterExpression(sarg); + Set<PartitionData> partitionList = Sets.newHashSet(); + try (CloseableIterable<FileScanTask> fileScanTasks = partitionsTable.newScan().planFiles()) { + fileScanTasks.forEach(task -> + partitionList.addAll(Sets.newHashSet(CloseableIterable.transform(task.asDataTask().rows(), row -> { + StructProjection data = row.get(PART_IDX, StructProjection.class); + PartitionData partitionData = IcebergTableUtil.toPartitionData(data, pSpec.partitionType()); + ResidualEvaluator resEval = ResidualEvaluator.of(pSpec, expression, false); + if (resEval.residualFor(partitionData).isEquivalentTo(Expressions.alwaysTrue())) { + return partitionData; + } else { Review Comment: remove `else` and just return null -- 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