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


##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/storage/compact/AlterTableCompactOperation.java:
##########
@@ -62,6 +65,17 @@ public AlterTableCompactOperation(DDLOperationContext 
context, AlterTableCompact
       throw new HiveException(ErrorMsg.NONACID_COMPACTION_NOT_SUPPORTED, 
table.getDbName(), table.getTableName());
     }
 
+    if (desc.getPartitionSpec() != null && 
!AlterTableUtils.isIdentityPartitionTable(table)) {
+      throw new HiveException("Compaction is not supported on the table " +
+          table.getDbName() + "." + table.getTableName() + " with non-identity 
partition spec");
+    }
+
+    if (desc.getPartitionSpec() != null && DDLUtils.isIcebergTable(table) && 

Review Comment:
   how about we expose isEligibleForCompaction via StorageHandler
   ````
     private boolean hasUndergonePartitionEvolution(Table table) {
       // If it is a table which has undergone partition evolution, return true.
       return table.currentSnapshot() != null &&
           table.currentSnapshot().allManifests(table.io()).parallelStream()
           .map(ManifestFile::partitionSpecId)
           .anyMatch(id -> id < table.spec().specId());
     }
   
     private boolean isIdentityPartitionTable(Table table) {
       return 
getPartitionTransformSpec(table).stream().map(TransformSpec::getTransformType)
         .allMatch(type -> type == TransformSpec.TransformType.IDENTITY);
     }
     
     public boolean isEligibleForCompaction(Table table, Map<String, String> 
partitionSpec) throws HiveException {
       if (partitionSpec != null) {
         if (hasUndergonePartitionEvolution(table)) {
           throw new HiveException("Compaction on partition level is not 
supported on the table " +
             table.getDbName() + "." + table.getTableName() + " which has 
undergone partition evolution");
         }
         if (isIdentityPartitionTable(table)) {
           throw new HiveException("Compaction is not supported on the table " +
             table.getDbName() + "." + table.getTableName() + " with 
non-identity partition spec");
         }
       }
       return true;
     }
   ````
   and call
   ````
       if (table.getStorageHandler() != null) {
         table.getStorageHandler().isEligibleForCompaction(table, 
partitionSpec);
       }
   ````
   



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