kasakrisz commented on code in PR #6582:
URL: https://github.com/apache/hive/pull/6582#discussion_r3726386095
##########
ql/src/test/queries/clientpositive/count_distinct_multi_col.q:
##########
@@ -0,0 +1,80 @@
+create table t (col1 string, col2 int, col3 int, col4 date);
+
+insert into t values
+ ('a', 1, 2, '2022-01-01'),
+ ('a', 1, 2, '2022-01-01'),
+ ('a', 1, 2, '2022-01-02'),
+ ('a', 1, 22, '2022-01-02'),
+ ('a', 11, 2, '2022-01-01'),
+ ('a', 11, 2, '2022-01-02');
+
+-- single-column: HiveExpandDistinctAggregatesRule matched -> two
HiveAggregate operators in plan
+explain cbo
+SELECT col1, col2, COUNT(DISTINCT col3) AS cnt
+FROM t
+GROUP BY col1, col2;
+
+SELECT col1, col2, COUNT(DISTINCT col3) AS cnt
+FROM t
+GROUP BY col1, col2
+ORDER BY col1, col2;
+
+-- multi-column: HiveExpandDistinctAggregatesRule !matched -> single
HiveAggregate operator
+explain cbo
+SELECT col1, col2, COUNT(DISTINCT col3, col4) AS cnt
+FROM t
+GROUP BY col1, col2;
+
+SELECT col1, col2, COUNT(DISTINCT col3, col4) AS cnt
+FROM t
+GROUP BY col1, col2
+ORDER BY col1, col2;
+
+-- 3-column: HiveExpandDistinctAggregatesRule !matched -> single HiveAggregate
operator
+explain cbo
+SELECT col1, COUNT(DISTINCT col2, col3, col4) AS cnt
Review Comment:
What is the difference in handling 2-column, 3-column, and n-column cases?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]