kasakrisz commented on code in PR #5096: URL: https://github.com/apache/hive/pull/5096#discussion_r1512155888
########## ql/src/java/org/apache/hadoop/hive/ql/ddl/view/materialized/alter/rebuild/AlterMaterializedViewRebuildAnalyzer.java: ########## @@ -353,29 +353,32 @@ private RelNode applyRecordIncrementalRebuildPlan( MaterializedViewRewritingRelVisitor visitor = new MaterializedViewRewritingRelVisitor(acidView); visitor.go(basePlan); - if (visitor.isRewritingAllowed()) { - if (!materialization.isSourceTablesUpdateDeleteModified()) { - // Trigger rewriting to remove UNION branch with MV + switch (visitor.getIncrementalRebuildMode()) { + case INSERT_ONLY: + if (materialization.isSourceTablesUpdateDeleteModified()) { + return calcitePreMVRewritingPlan; + } + if (visitor.isContainsAggregate()) { return applyAggregateInsertIncremental(basePlan, mdProvider, executorProvider, optCluster, calcitePreMVRewritingPlan); } else { return applyJoinInsertIncremental(basePlan, mdProvider, executorProvider); } - } else { - // 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 - if (acidView && visitor.isContainsAggregate() && visitor.getCountIndex() >= 0) { - return applyAggregateInsertDeleteIncremental(basePlan, mdProvider, executorProvider); + case AVAILABLE: + if (!materialization.isSourceTablesUpdateDeleteModified()) { + return applyAggregateInsertIncremental(basePlan, mdProvider, executorProvider, optCluster, calcitePreMVRewritingPlan); } else { + return applyAggregateInsertDeleteIncremental(basePlan, mdProvider, executorProvider); + } + case NOT_AVAILABLE: + default: + if (materialization.isSourceTablesUpdateDeleteModified()) { + // calcitePreMVRewritingPlan is already got the optimizations by applyPreJoinOrderingTransforms prior calling Review Comment: fixed -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org