deniskuzZ commented on code in PR #5123:
URL: https://github.com/apache/hive/pull/5123#discussion_r1569000652
##########
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:
````
else {
sessionState.setConf(conf);
}
````
--
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]