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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]