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

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

                Author: ASF GitHub Bot
            Created on: 19/Mar/21 09:25
            Start Date: 19/Mar/21 09:25
    Worklog Time Spent: 10m 
      Work Description: pvary commented on a change in pull request #2088:
URL: https://github.com/apache/hive/pull/2088#discussion_r597523188



##########
File path: 
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestMaterializedViewRebuild.java
##########
@@ -0,0 +1,152 @@
+/*
+ * 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.txn.compactor;
+
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.hadoop.hive.metastore.api.CompactionType;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static 
org.apache.hadoop.hive.ql.txn.compactor.TestCompactor.executeStatementOnDriver;
+import static 
org.apache.hadoop.hive.ql.txn.compactor.TestCompactor.execSelectAndDumpData;
+import static 
org.apache.hadoop.hive.ql.txn.compactor.TestCompactor.executeStatementOnDriverSiletnly;
+
+public class TestMaterializedViewRebuild extends CompactorOnTezTest {
+
+  private static final String TABLE1 = "t1";
+  private static final String MV1 = "mat1";
+
+  private static final List<String> FULL_REBUILD_PLAN = Arrays.asList(
+      "CBO PLAN:",
+      "HiveProject(a=[$0], b=[$1], c=[$2])",
+      "  HiveFilter(condition=[OR(IS NULL($0), >($0, 0))])",
+      "    HiveTableScan(table=[[default, t1]], table:alias=[t1])",
+      ""
+  );
+
+  private static final List<String> INCREMENTAL_REBUILD_PLAN = Arrays.asList(
+      "CBO PLAN:",
+      "HiveProject(a=[$0], b=[$1], c=[$2])",
+      "  HiveFilter(condition=[AND(<(2, $5.writeid), OR(>($0, 0), IS 
NULL($0)))])",
+      "    HiveTableScan(table=[[default, t1]], table:alias=[t1])",
+      ""
+  );
+
+  private static final List<String> EXPECTED_RESULT = Arrays.asList(
+      "1\tone\t1.1",
+      "2\ttwo\t2.2",
+      "3\tthree\t3.3",
+      "NULL\tNULL\tNULL"
+  );
+
+
+  @Override
+  public void setup() throws Exception {
+    super.setup();
+
+    executeStatementOnDriver("create table " + TABLE1 + "(a int, b 
varchar(128), c float) stored as orc TBLPROPERTIES ('transactional'='true')", 
driver);
+    executeStatementOnDriver("insert into " + TABLE1 + "(a,b, c) values (1, 
'one', 1.1), (2, 'two', 2.2), (NULL, NULL, NULL)", driver);
+    executeStatementOnDriver("create materialized view " + MV1 + " stored as 
orc TBLPROPERTIES ('transactional'='true') as " +
+        "select a,b,c from " + TABLE1 + " where a > 0 or a is null", driver);
+  }
+
+  @Override
+  public void tearDown() {
+    executeStatementOnDriverSiletnly("drop materialized view " + MV1, driver);

Review comment:
       nit: typo




-- 
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:
us...@infra.apache.org


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

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

> Materialized View incremental rebuild produces wrong result set after 
> compaction
> --------------------------------------------------------------------------------
>
>                 Key: HIVE-24840
>                 URL: https://issues.apache.org/jira/browse/HIVE-24840
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Krisztian Kasa
>            Assignee: Krisztian Kasa
>            Priority: Critical
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> {code}
> create table t1(a int, b varchar(128), c float) stored as orc TBLPROPERTIES 
> ('transactional'='true');
> insert into t1(a,b, c) values (1, 'one', 1.1), (2, 'two', 2.2), (NULL, NULL, 
> NULL);
> create materialized view mat1 stored as orc TBLPROPERTIES 
> ('transactional'='true') as 
>             select a,b,c from t1 where a > 0 or a is null;
> delete from t1 where a = 1;
> alter table t1 compact 'major';
> -- Wait until compaction finished.
> alter materialized view mat1 rebuild;
> {code}
> Expected result of query
> {code}
> select * from mat1;
> {code}
> {code}
> 2 two 2
> NULL NULL NULL
> {code}
> but if incremental rebuild is enabled the result is
> {code}
> 1 one 1
> 2 two 2
> NULL NULL NULL
> {code}
> Cause: Incremental rebuild queries whether the source tables of a 
> materialized view has delete or update transaction since the last rebuild 
> from metastore from COMPLETED_TXN_COMPONENTS table. However when a major 
> compaction is performed on the source tables the records related to these 
> tables are deleted from COMPLETED_TXN_COMPONENTS.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to