kasakrisz commented on code in PR #6988:
URL: https://github.com/apache/hive/pull/6988#discussion_r4754554346


##########
ql/src/test/queries/clientpositive/aggregate_join_transpose_unique.q:
##########
@@ -0,0 +1,20 @@
+-- SORT_QUERY_RESULTS
+
+create table ajt_dim (x int, k int, y int, primary key (k) disable novalidate 
rely);
+create table ajt_dim_nopk (k int, x int);
+create table ajt_fact (fk int);
+insert into ajt_dim values (10, 1, 100), (20, 2, 200), (null, 3, 300);
+insert into ajt_dim_nopk values (1, 10), (2, 20), (3, null);
+insert into ajt_fact values (1), (1), (2), (3), (3), (3);
+
+explain cbo
+select k, sum(x), min(x), max(x), count(x), count(*) from ajt_dim join 
ajt_fact on k = fk group by k;
+select k, sum(x), min(x), max(x), count(x), count(*) from ajt_dim join 
ajt_fact on k = fk group by k;

Review Comment:
   I added test and `ajt_dim` stays on the right.
   Before
   ```
   HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[min($1)], 
agg#2=[max($1)], agg#3=[count($1)], agg#4=[count()])
     HiveProject($f0=[$2], $f1=[$1])
       HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], 
cost=[not available])
         HiveProject(fk=[$0])
           HiveFilter(condition=[IS NOT NULL($0)])
             HiveTableScan(table=[[default, ajt_fact]], table:alias=[ajt_fact])
         HiveProject(x=[$0], k=[$1])
           HiveTableScan(table=[[default, ajt_dim]], table:alias=[ajt_dim])
   ```
   after
   ```
   HiveProject(k=[$2], $f7=[*($1, $3)], x0=[$4], x1=[$5], $f8=[*($1, $6)], 
count=[$1])
     HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], 
cost=[not available])
       HiveAggregate(group=[{0}], count=[count()])
         HiveProject(fk=[$0])
           HiveFilter(condition=[IS NOT NULL($0)])
             HiveTableScan(table=[[default, ajt_fact]], table:alias=[ajt_fact])
       HiveProject(k=[$1], x=[$0], x0=[$0], x1=[$0], $f4=[CASE(IS NOT NULL($0), 
1:BIGINT, 0:BIGINT)])
         HiveTableScan(table=[[default, ajt_dim]], table:alias=[ajt_dim])
   ```



-- 
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]

Reply via email to