kuczoram commented on code in PR #5192:
URL: https://github.com/apache/hive/pull/5192#discussion_r1601493512


##########
ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/CompactionQueryBuilderForInsertOnly.java:
##########
@@ -0,0 +1,265 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.txn.compactor;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.hive.common.StatsSetupConst;
+import org.apache.hadoop.hive.metastore.api.*;
+import org.apache.hadoop.hive.ql.exec.DDLPlanUtils;
+import org.apache.hadoop.hive.ql.util.DirectionUtils;
+import org.apache.hive.common.util.HiveStringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.*;
+
+/**
+ * Builds query strings that help with query-based compaction of insert-only 
tables.
+ */
+class CompactionQueryBuilderForInsertOnly extends CompactionQueryBuilder {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(CompactionQueryBuilderForInsertOnly.class.getName());
+
+  /**
+   * Construct a CompactionQueryBuilderForInsertOnly with required params.
+   *
+   * @param compactionType major or minor or rebalance, e.g. 
CompactionType.MAJOR.
+   *                       Cannot be null.
+   *                       Rebalance compaction is not supported for 
insert-only tables.
+   * @throws IllegalArgumentException if compactionType is null or the 
compaction type is REBALANCE
+   */
+  CompactionQueryBuilderForInsertOnly(CompactionType compactionType) {
+    super(compactionType, true);
+    if (CompactionType.REBALANCE.equals(compactionType)) {
+      throw new IllegalArgumentException("Rebalance compaction can only be 
supported on full ACID tables.");
+    }
+  }
+
+  @Override
+  protected void buildSelectClauseForInsert(StringBuilder query) {
+    switch (compactionType) {

Review Comment:
   I see you point. But the insert-only compaction is kind of a special case. I 
would like to keep it separately from the ACID compactions. The original aim 
was to be able to change things in the compaction query generation logic more 
easily and by not breaking the other types of compactions. In my head, the 
separation was always like 'MAJOR', 'MINOR' and the compactions for the 
insert-only tables, because they are kind of specials. I would rather not put 
the insert-only logic into the acid compactions. I am ok to create separate 
files for the insert-only MAJOR and MINOR, so we can get rid of this switch 
case, but I wouldn't like to put the 'if (insertOnly)' choices into the MAJOR 
and MINOR compaction code.



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