amansinha100 commented on a change in pull request #2881:
URL: https://github.com/apache/hive/pull/2881#discussion_r801882163



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/views/HiveScanCostSetterRule.java
##########
@@ -0,0 +1,83 @@
+package org.apache.hadoop.hive.ql.optimizer.calcite.rules.views;/*
+ * 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.
+ */
+
+import org.apache.calcite.plan.RelOptMaterialization;
+import org.apache.calcite.plan.RelOptRule;
+import org.apache.calcite.plan.RelOptRuleCall;
+import org.apache.calcite.rel.core.TableScan;
+import org.apache.hadoop.hive.common.TableName;
+import org.apache.hadoop.hive.metastore.api.SourceTable;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.ql.metadata.MaterializedViewMetadata;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveRelFactories;
+import org.apache.hadoop.hive.ql.optimizer.calcite.RelOptHiveTable;
+import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveTableScan;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class HiveScanCostSetterRule extends RelOptRule {

Review comment:
       Could you add a comment about the intent of this rule ?

##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/ddl/view/materialized/alter/rebuild/AlterMaterializedViewRebuildAnalyzer.java
##########
@@ -399,8 +402,35 @@ private RelNode applyPartitionIncrementalRebuildPlan(
         return applyPreJoinOrderingTransforms(basePlan, mdProvider, 
executorProvider);
       }
 
-      return applyIncrementalRebuild(basePlan, mdProvider, executorProvider,
-              HiveInsertOnlyScanWriteIdRule.INSTANCE, 
HiveAggregatePartitionIncrementalRewritingRule.INSTANCE);
+      RelNode incrementalRebuildPlan = applyIncrementalRebuild(basePlan, 
mdProvider, executorProvider,
+              HiveInsertOnlyScanWriteIdRule.INSTANCE,
+              HiveAggregatePartitionIncrementalRewritingRule.INSTANCE);
+
+      HepProgramBuilder program = new HepProgramBuilder();
+      generatePartialProgram(program, false, HepMatchOrder.DEPTH_FIRST, 
HiveScanCostSetterRule.with(materialization));
+      incrementalRebuildPlan = executeProgram(incrementalRebuildPlan, 
program.build(), mdProvider, executorProvider);
+
+      // Make a cost-based decision factoring the configuration property
+      optCluster.invalidateMetadataQuery();
+      
RelMetadataQuery.THREAD_PROVIDERS.set(HiveTezModelRelMetadataProvider.DEFAULT);
+      try {
+        // Multiply by 10.0 because this config is also used in 
applyAggregateInsertIncremental
+        final double factorSelectivity = HiveConf.getFloatVar(
+                conf, 
HiveConf.ConfVars.HIVE_MATERIALIZED_VIEW_REBUILD_INCREMENTAL_FACTOR) * 10.0;

Review comment:
       It wasn't clear why the magic factor of 10 was chosen and why the 
existing config was not sufficient. 




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