deniskuzZ commented on code in PR #5123:
URL: https://github.com/apache/hive/pull/5123#discussion_r1575794099


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandler.java:
##########
@@ -1915,6 +1917,46 @@ private boolean hasUndergonePartitionEvolution(Table 
table) {
         .anyMatch(id -> id < table.spec().specId());
   }
 
+  private boolean 
isIdentityPartitionTable(org.apache.hadoop.hive.ql.metadata.Table table) {
+    return 
getPartitionTransformSpec(table).stream().map(TransformSpec::getTransformType)
+        .allMatch(type -> type == TransformSpec.TransformType.IDENTITY);
+  }
+
+  @Override
+  public org.apache.commons.lang3.tuple.Pair<Boolean, ErrorMsg> 
isEligibleForCompaction(
+      org.apache.hadoop.hive.ql.metadata.Table table, Map<String, String> 
partitionSpec) {
+    if (partitionSpec != null) {
+      Table icebergTable = IcebergTableUtil.getTable(conf, table.getTTable());
+      if (hasUndergonePartitionEvolution(icebergTable)) {
+        return org.apache.commons.lang3.tuple.Pair.of(false, 
ErrorMsg.COMPACTION_PARTITION_EVOLUTION);
+      }
+      if (!isIdentityPartitionTable(table)) {
+        return org.apache.commons.lang3.tuple.Pair.of(false, 
ErrorMsg.COMPACTION_NON_IDENTITY_PARTITION_SPEC);
+      }
+    }
+    return org.apache.commons.lang3.tuple.Pair.of(true, null);
+  }
+
+  @Override
+  public List<Partition> 
getPartitions(org.apache.hadoop.hive.ql.metadata.Table table,
+      Map<String, String> partitionSpec, short limit) throws SemanticException 
{
+    return table.getStorageHandler().getPartitionNames(table, 
partitionSpec).stream()
+        .limit(limit > 0 ? limit : Long.MAX_VALUE)
+        .map(partName -> new DummyPartition(table, partName, 
partitionSpec)).collect(Collectors.toList());
+  }
+
+  @Override
+  public Partition getPartition(org.apache.hadoop.hive.ql.metadata.Table table,
+      Map<String, String> partitionSpec) throws SemanticException {
+    validatePartSpec(table, partitionSpec);
+    try {
+      String partName = Warehouse.makePartName(partitionSpec, false);
+      return new DummyPartition(table, partName, partitionSpec);
+    } catch (MetaException e) {

Review Comment:
   you should throw `MetaException` and catch it in the orig place - Analyzer



-- 
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]

Reply via email to