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


##########
ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/CompactorFactory.java:
##########
@@ -48,39 +56,54 @@ private QueryCompactorFactory() {
    * <br>
    * {@link MmMinorQueryCompactor} - handles query based minor compaction for 
micro-managed tables
    * <br>
+   * {@link MRCompactor} - handles MR based minor, major, or rebalance 
compaction
+   * <br>
+   * {@link RebalanceQueryCompactor} - handles query based rebalance compaction
+   * <br>
    * </p>
+   * @param msc The {@link IMetaStoreClient} instance is used only by the 
{@link MRCompactor}.
    * @param table the table, on which the compaction should be running, must 
be not null.
    * @param configuration the hive configuration, must be not null.
    * @param compactionInfo provides insight about the type of compaction, must 
be not null.
    * @return {@link QueryCompactor} or null.
    */
-  static QueryCompactor getQueryCompactor(Table table, HiveConf configuration, 
CompactionInfo compactionInfo)
+  public Compactor getQueryCompactor(IMetaStoreClient msc, Table table, 
HiveConf configuration, CompactionInfo compactionInfo)
       throws HiveException {
-    if (!AcidUtils.isInsertOnlyTable(table.getParameters())
-        && HiveConf.getBoolVar(configuration, 
HiveConf.ConfVars.COMPACTOR_CRUD_QUERY_BASED)) {
-      if (!"tez".equalsIgnoreCase(HiveConf.getVar(configuration, 
HiveConf.ConfVars.HIVE_EXECUTION_ENGINE))) {
+    if (AcidUtils.isFullAcidTable(table.getParameters())) {
+      if (!"tez".equalsIgnoreCase(HiveConf.getVar(configuration, 
HiveConf.ConfVars.HIVE_EXECUTION_ENGINE)) ||
+          !HiveConf.getBoolVar(configuration, 
HiveConf.ConfVars.COMPACTOR_CRUD_QUERY_BASED)) {
+        if (CompactionType.REBALANCE.equals(compactionInfo.type)) {
+          throw new HiveException("Rebalancing compaction is only supported in 
Tez, and via Query based compaction. " +
+              "Set hive.execution.engine=tez and 
hive.compactor.crud.query.based=true to enable it.");
+        }
         LOG.info("Query-based compaction is only supported on tez. Falling 
back to MR compaction.");
-        return null;
+        return new MRCompactor(msc);
       }
-      if (compactionInfo.isMajorCompaction()) {
-        return new MajorQueryCompactor();
-      } else {
-        return new MinorQueryCompactor();
+      switch (compactionInfo.type) {
+        case MINOR:
+          return new MinorQueryCompactor();
+        case MAJOR:
+          return new MajorQueryCompactor();
+        case REBALANCE:
+          return new RebalanceQueryCompactor();
       }
-    }
-    if (AcidUtils.isInsertOnlyTable(table.getParameters())) {
+    } else if (AcidUtils.isInsertOnlyTable(table.getParameters())) {
       if 
(!configuration.getBoolVar(HiveConf.ConfVars.HIVE_COMPACTOR_COMPACT_MM)) {
         throw new HiveException(
-            "Insert only compaction is disabled. Set 
hive.compactor.compact.insert.only to true to enable it.");
+            "Insert only compaction is disabled. Set 
hive.compactor.compact.insert.only=true to enable it.");
       }
-      if (compactionInfo.isMajorCompaction()) {
-        return new MmMajorQueryCompactor();
-      } else {
-        return new MmMinorQueryCompactor();
+      switch (compactionInfo.type) {
+        case MINOR:
+          return new MmMinorQueryCompactor();
+        case MAJOR:
+          return new MmMajorQueryCompactor();
+        case REBALANCE:

Review Comment:
   should be under default:
   compactionInfo.type + compaction is not supported on insert only tables.



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