You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2021/06/24 09:07:34 UTC

[GitHub] [hive] kasakrisz commented on a change in pull request #2401: HIVE-25253: Incremental rebuild of partitioned insert only materialized views

kasakrisz commented on a change in pull request #2401:
URL: https://github.com/apache/hive/pull/2401#discussion_r657768898



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/ddl/view/materialized/alter/rebuild/AlterMaterializedViewRebuildAnalyzer.java
##########
@@ -261,41 +263,61 @@ protected RelNode applyMaterializedViewRewriting(RelOptPlanner planner, RelNode
         if (materialization.isSourceTablesCompacted()) {
           return calcitePreMVRewritingPlan;
         }
-        // First we need to check if it is valid to convert to MERGE/INSERT INTO.
-        // If we succeed, we modify the plan and afterwards the AST.
-        // MV should be an acid table.
-        MaterializedViewRewritingRelVisitor visitor = new MaterializedViewRewritingRelVisitor();
-        visitor.go(basePlan);
-        if (visitor.isRewritingAllowed()) {
-          if (materialization.isSourceTablesUpdateDeleteModified()) {
-            if (visitor.isContainsAggregate()) {
-              if (visitor.getCountIndex() < 0) {
-                // count(*) is necessary for determine which rows should be deleted from the view
-                // if view definition does not have it incremental rebuild can not be performed, bail out
-                return calcitePreMVRewritingPlan;
-              }
-              return toAggregateInsertDeleteIncremental(basePlan, mdProvider, executorProvider);
-            } else {
-              return toJoinInsertDeleteIncremental(
-                      basePlan, mdProvider, executorProvider, optCluster, calcitePreMVRewritingPlan);
-            }
-          } else {
-            // Trigger rewriting to remove UNION branch with MV
-            if (visitor.isContainsAggregate()) {
-              return toAggregateInsertIncremental(basePlan, mdProvider, executorProvider, optCluster, calcitePreMVRewritingPlan);
-            } else {
-              return toJoinInsertIncremental(basePlan, mdProvider, executorProvider);
-            }
-          }
-        } else if (materialization.isSourceTablesUpdateDeleteModified()) {
-          return calcitePreMVRewritingPlan;
+
+        RelNode incrementalRebuildPlan = toIncrementalRebuild(

Review comment:
       renamed

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/ddl/view/materialized/alter/rebuild/AlterMaterializedViewRebuildAnalyzer.java
##########
@@ -261,41 +263,61 @@ protected RelNode applyMaterializedViewRewriting(RelOptPlanner planner, RelNode
         if (materialization.isSourceTablesCompacted()) {
           return calcitePreMVRewritingPlan;
         }
-        // First we need to check if it is valid to convert to MERGE/INSERT INTO.
-        // If we succeed, we modify the plan and afterwards the AST.
-        // MV should be an acid table.
-        MaterializedViewRewritingRelVisitor visitor = new MaterializedViewRewritingRelVisitor();
-        visitor.go(basePlan);
-        if (visitor.isRewritingAllowed()) {
-          if (materialization.isSourceTablesUpdateDeleteModified()) {
-            if (visitor.isContainsAggregate()) {
-              if (visitor.getCountIndex() < 0) {
-                // count(*) is necessary for determine which rows should be deleted from the view
-                // if view definition does not have it incremental rebuild can not be performed, bail out
-                return calcitePreMVRewritingPlan;
-              }
-              return toAggregateInsertDeleteIncremental(basePlan, mdProvider, executorProvider);
-            } else {
-              return toJoinInsertDeleteIncremental(
-                      basePlan, mdProvider, executorProvider, optCluster, calcitePreMVRewritingPlan);
-            }
-          } else {
-            // Trigger rewriting to remove UNION branch with MV
-            if (visitor.isContainsAggregate()) {
-              return toAggregateInsertIncremental(basePlan, mdProvider, executorProvider, optCluster, calcitePreMVRewritingPlan);
-            } else {
-              return toJoinInsertIncremental(basePlan, mdProvider, executorProvider);
-            }
-          }
-        } else if (materialization.isSourceTablesUpdateDeleteModified()) {
-          return calcitePreMVRewritingPlan;
+
+        RelNode incrementalRebuildPlan = toIncrementalRebuild(
+                basePlan, mdProvider, executorProvider, optCluster, calcitePreMVRewritingPlan, materialization);
+        if (mvRebuildMode != MaterializationRebuildMode.INSERT_OVERWRITE_REBUILD) {
+          return incrementalRebuildPlan;
         }
+
+        return toPartitionInsertOverwrite(

Review comment:
       renamed




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org