prql
prql copied to clipboard
count_distinct this => COUNT(DISTINCT t.*)
trafficstars
What's up?
I noticed that
count_distinct this
translates to
COUNT(DISTINCT this) OVER ()`
I would expect it to translate into
COUNT(DISTINCT t.*)
(where t is table name)
One thing is extra OVER () which AFAIR is discussed in another issue, so lets not focus on this here.
I am filling this issue with a focus of translating this into t.*, which is valid postgres syntax.
http://sqlfiddle.com/#!17/d8c19/4
create table t1 (a1 integer, a2 integer);
insert into t1 values (1, 2);
insert into t1 values (1, 2);
insert into t1 values (1, 3);
select count(a1) from t1;
select count(*) from t1;
select count(distinct a1) from t1;
select count(distinct t1.*) from t1;
Gives
3
3
1
2
I agree re compiling to COUNT(DISTINCT t.*).
Do we know whether other DBs support this?
I am aware if any, and postgres requires table alias prefix to star, star alone won't work.