You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/02/08 17:28:00 UTC

[jira] [Work logged] (HIVE-25747) Make a cost base decision when rebuilding materialized views

     [ https://issues.apache.org/jira/browse/HIVE-25747?focusedWorklogId=723018&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-723018 ]

ASF GitHub Bot logged work on HIVE-25747:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 08/Feb/22 17:27
            Start Date: 08/Feb/22 17:27
    Worklog Time Spent: 10m 
      Work Description: 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: gitbox-unsubscribe@hive.apache.org

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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 723018)
    Time Spent: 20m  (was: 10m)

> Make a cost base decision when rebuilding materialized views
> ------------------------------------------------------------
>
>                 Key: HIVE-25747
>                 URL: https://issues.apache.org/jira/browse/HIVE-25747
>             Project: Hive
>          Issue Type: Improvement
>          Components: CBO, Materialized views
>            Reporter: Krisztian Kasa
>            Assignee: Krisztian Kasa
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Choose between full insert-overwrite and partition based incremental rebuild plan when rebuilding partitioned materialized views.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)