jcamachor commented on a change in pull request #960: HIVE-23030 ds rollup union
URL: https://github.com/apache/hive/pull/960#discussion_r397519890
##########
File path: ql/src/test/queries/clientpositive/sketches_rollup.q
##########
@@ -0,0 +1,40 @@
+
+set hive.support.concurrency=true;
+set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
+set hive.strict.checks.cartesian.product=false;
+set hive.stats.fetch.column.stats=true;
+set hive.materializedview.rewriting=true;
+set hive.fetch.task.conversion=none;
+
+create table sketch_input (id int, category char(1))
+STORED AS ORC
+TBLPROPERTIES ('transactional'='true');
+
+insert into table sketch_input values
+ (1,'a'),(1, 'a'), (2, 'a'), (3, 'a'), (4, 'a'), (5, 'a'), (6, 'a'), (7,
'a'), (8, 'a'), (9, 'a'), (10, 'a'),
+ (6,'b'),(6, 'b'), (7, 'b'), (8, 'b'), (9, 'b'), (10, 'b'), (11, 'b'), (12,
'b'), (13, 'b'), (14, 'b'), (15, 'b')
+;
+
+-- create an mv for the intermediate results
+create materialized view mv_1 as
+ select category, ds_hll_sketch(id),count(id) from sketch_input group by
category;
+
+-- see if we use the mv
+explain
+select category, ds_hll_estimate(ds_hll_sketch(id)) from sketch_input group by
category;
+
+select category, ds_hll_estimate(ds_hll_sketch(id)) from sketch_input group by
category;
+
+-- union sketches across categories and get overall unique count estimate
+explain
+select ds_hll_estimate(ds_hll_sketch(id)) from sketch_input group by category;
+select ds_hll_estimate(ds_hll_sketch(id)) from sketch_input group by category;
+
+-- see how well mv/count works
+explain
+select count(id) from sketch_input;
Review comment:
Should we run `count distinct` here instead of explain on count?
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]