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

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

                Author: ASF GitHub Bot
            Created on: 28/Apr/21 06:13
            Start Date: 28/Apr/21 06:13
    Worklog Time Spent: 10m 
      Work Description: jcamachor commented on a change in pull request #2196:
URL: https://github.com/apache/hive/pull/2196#discussion_r621843889



##########
File path: 
ql/src/test/queries/clientpositive/materialized_view_create_rewrite_6.q
##########
@@ -0,0 +1,75 @@
+set hive.support.concurrency=true;
+set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
+set hive.materializedview.rewriting.sql=false;
+
+create table t1(a char(15), b int, c int) stored as orc TBLPROPERTIES 
('transactional'='true');
+create table t2(a char(15), b int) stored as orc TBLPROPERTIES 
('transactional'='true');
+
+insert into t1(a, b, c) values
+('update', 1, 1), ('update', 2, 1),
+('null_update', null, 1), ('null_update', null, 2);
+insert into t1(a, b, c) values ('remove', 3, 1), ('null_remove', null, 1);
+insert into t1(a, b, c) values ('sum0', 0, 1), ('sum0', 0, 2);
+
+insert into t2(a, b) values
+('update', 10),
+('null_update', null);
+insert into t2(a, b) values ('remove', 30), ('null_remove', null);
+insert into t2(a, b) values ('sum0', 0);
+
+-- Aggregate with count(*): incremental rebuild should be triggered even if 
there were deletes from source table
+create materialized view mat1 stored as orc TBLPROPERTIES 
('transactional'='true') as
+select t1.a, sum(t1.b), count(*) from t1
+join t2 on (t1.a = t2.a)
+group by t1.a;
+
+
+explain cbo
+select t1.a, sum(t1.b) from t1
+join t2 on (t1.a = t2.a)
+group by t1.a;
+
+-- do some changes on source table data
+delete from t1 where b = 1;
+delete from t1 where a = 'remove';
+delete from t1 where c = 2;
+
+insert into t1(a,b,c) values
+('update', 5, 1),
+('add', 5, 1),
+('add/remove', 0, 0),
+('null_update', null, 0),
+('null_add', null, 0),
+('null_add/remove', null, 0);
+
+delete from t1 where a like 'add/remove';
+
+-- view can not be used
+explain cbo
+select t1.a, sum(t1.b) from t1
+join t2 on (t1.a = t2.a)
+group by t1.a;
+
+
+-- rebuild the view (incrementally)
+explain cbo
+alter materialized view mat1 rebuild;
+explain
+alter materialized view mat1 rebuild;
+alter materialized view mat1 rebuild;

Review comment:
       Does this example contain rows that hit the three branches in the merge, 
i.e., insert, update, delete?




-- 
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: 590162)
    Time Spent: 40m  (was: 0.5h)

> Incremental rebuild of MV having aggregate in presence of delete operation
> --------------------------------------------------------------------------
>
>                 Key: HIVE-24992
>                 URL: https://issues.apache.org/jira/browse/HIVE-24992
>             Project: Hive
>          Issue Type: Improvement
>          Components: Materialized views
>            Reporter: Krisztian Kasa
>            Assignee: Krisztian Kasa
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Extension of HIVE-24854: handle cases when the Materialized view definition 
> has aggregation like
> {code}
> CREATE MATERIALIZED VIEW cmv_mat_view_n5 DISABLE REWRITE TBLPROPERTIES 
> ('transactional'='true') AS
>   SELECT cmv_basetable_n5.a, cmv_basetable_2_n2.c, sum(cmv_basetable_2_n2.d)
>   FROM cmv_basetable_n5 JOIN cmv_basetable_2_n2 ON (cmv_basetable_n5.a = 
> cmv_basetable_2_n2.a)
>   WHERE cmv_basetable_2_n2.c > 10.0
>   GROUP BY cmv_basetable_n5.a, cmv_basetable_2_n2.c;
> {code}



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

Reply via email to