[ https://issues.apache.org/jira/browse/HIVE-25546?focusedWorklogId=658350&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-658350 ]
ASF GitHub Bot logged work on HIVE-25546: ----------------------------------------- Author: ASF GitHub Bot Created on: 30/Sep/21 13:37 Start Date: 30/Sep/21 13:37 Worklog Time Spent: 10m Work Description: kasakrisz commented on a change in pull request #2663: URL: https://github.com/apache/hive/pull/2663#discussion_r719415132 ########## File path: ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/views/HiveInsertOnlyScanWriteIdRule.java ########## @@ -0,0 +1,56 @@ +/* + * 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.optimizer.calcite.rules.views; + +import org.apache.calcite.plan.RelOptRule; +import org.apache.calcite.plan.RelOptRuleCall; +import org.apache.calcite.rel.RelNode; +import org.apache.hadoop.hive.ql.io.AcidUtils; +import org.apache.hadoop.hive.ql.metadata.Table; +import org.apache.hadoop.hive.ql.optimizer.calcite.RelOptHiveTable; +import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveTableScan; + +import static org.apache.hadoop.hive.conf.Constants.INSERT_ONLY_FETCH_BUCKET_ID; + +/** + * This rule turns on populating writeId of insert only table scans. + */ +public class HiveInsertOnlyScanWriteIdRule extends RelOptRule { + + public static final HiveInsertOnlyScanWriteIdRule INSTANCE = new HiveInsertOnlyScanWriteIdRule(); + + private HiveInsertOnlyScanWriteIdRule() { + super(operand(HiveTableScan.class, none())); + } + + @Override + public boolean matches(RelOptRuleCall call) { + HiveTableScan tableScan = call.rel(0); + Table tableMD = ((RelOptHiveTable) tableScan.getTable()).getHiveTableMD(); + return !tableMD.isMaterializedView() && AcidUtils.isInsertOnlyTable(tableMD); + } + + @Override + public void onMatch(RelOptRuleCall call) { + HiveTableScan tableScan = call.rel(0); + RelNode newTableScan = call.builder() + .push(tableScan.setTableScanTrait(HiveTableScan.HiveTableScanTrait.FetchInsertOnlyBucketIds)) Review comment: Sure. Added these details to the javadocs. -- 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 Issue Time Tracking ------------------- Worklog Id: (was: 658350) Time Spent: 3h (was: 2h 50m) > Enable incremental rebuild of Materialized views with insert only source > tables > ------------------------------------------------------------------------------- > > Key: HIVE-25546 > URL: https://issues.apache.org/jira/browse/HIVE-25546 > Project: Hive > Issue Type: Improvement > Components: CBO, Materialized views > Reporter: Krisztian Kasa > Assignee: Krisztian Kasa > Priority: Major > Labels: pull-request-available > Time Spent: 3h > Remaining Estimate: 0h > > {code} > create table t1(a int, b int, c int) stored as parquet TBLPROPERTIES > ('transactional'='true', 'transactional_properties'='insert_only'); > create materialized view mat1 stored as orc TBLPROPERTIES > ('transactional'='true') as > select a, b, c from t1 where a > 10; > {code} > Currently materialized view *mat1* can not be rebuilt incrementally because > it has an insert only source table (t1). Such tables does not have > ROW_ID.write_id which is required to identify newly inserted records since > the last rebuild. > HIVE-25406 adds the ability to query write_id. -- This message was sent by Atlassian Jira (v8.3.4#803005)