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


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/compaction/IcebergMajorQueryCompactor.java:
##########
@@ -44,22 +51,69 @@ public boolean run(CompactorContext context) throws 
IOException, HiveException,
     Map<String, String> tblProperties = context.getTable().getParameters();
     LOG.debug("Initiating compaction for the {} table", compactTableName);
 
-    String compactionQuery = String.format("insert overwrite table %s select * 
from %<s",
-        compactTableName);
+    HiveConf conf = new HiveConf(context.getConf());
+    String partSpec = context.getCompactionInfo().partName;
+    String compactionQuery;
+
+    if (partSpec == null) {
+      HiveConf.setVar(conf, ConfVars.REWRITE_POLICY, 
RewritePolicy.ALL_PARTITIONS.name());
+      compactionQuery = String.format("insert overwrite table %s select * from 
%<s", compactTableName);
+    } else {
+      Table table = IcebergTableUtil.getTable(conf, context.getTable());
+      PartitionData partitionData = DataFiles.data(table.spec(), partSpec);
+      compactionQuery = String.format("insert overwrite table %1$s 
partition(%2$s) select * from %1$s where %3$s",
+          compactTableName, partDataToSQL(partitionData, partSpec, ","),
+          partDataToSQL(partitionData, partSpec, " and "));
+    }
+
+    SessionState sessionState = setupQueryCompactionSession(conf, 
context.getCompactionInfo(), tblProperties);
+    sessionState.setConf(conf);

Review Comment:
   won't that override the conf setup in setupQueryCompactionSession
   ````
       Util.disableLlapCaching(conf);
       conf.set(HiveConf.ConfVars.HIVE_QUOTEDID_SUPPORT.varname, "column");
       conf.setBoolVar(HiveConf.ConfVars.HIVE_SERVER2_ENABLE_DOAS, true);
       conf.setBoolVar(HiveConf.ConfVars.HIVE_HDFS_ENCRYPTION_SHIM_CACHE_ON, 
false);
       Util.overrideConfProps(conf, compactionInfo, tblProperties);
   ````



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