Thread: Todo item: distinct clause - guidance

Todo item: distinct clause - guidance

From
Ankit Kumar Pandey
Date:

Hi,

I was looking for some to-do item to pick up and came across 'Implement DISTINCT clause in window aggregates'. Can someone please elaborate what is expectation here? Do feature request still exists as DISTINCT worked as expected if we try functions like avg(distinct col)?

Thanks,

Ankit

Re: Todo item: distinct clause - guidance

From
Laurenz Albe
Date:
On Sun, 2022-11-06 at 18:39 +0530, Ankit Kumar Pandey wrote:
> I was looking for some to-do item to pick up and came across 'Implement DISTINCT
> clause in window aggregates'. Can someone pleaseelaborate what is expectation here?
> Do feature request still exists as DISTINCT worked as expected if we try functions
> like avg(distinct col)?

Whis is about window functions, like

  WITH q(a,b) AS (VALUES (1, 1), (1, 1), (2, 1))
  SELECT *,
         count(DISTINCT a) OVER (PARTITION BY b)
  FROM q;

  ERROR:  DISTINCT is not implemented for window functions
  LINE 3:        count(DISTINCT a) OVER (PARTITION BY b)
                 ^

Yours,
Laurenz Albe



Re: Todo item: distinct clause - guidance

From
Ankit Kumar Pandey
Date:
On 07/11/22 00:42, Laurenz Albe wrote:
> On Sun, 2022-11-06 at 18:39 +0530, Ankit Kumar Pandey wrote:
>> I was looking for some to-do item to pick up and came across 'Implement DISTINCT
>> clause in window aggregates'. Can someone pleaseelaborate what is expectation here?
>> Do feature request still exists as DISTINCT worked as expected if we try functions
>> like avg(distinct col)?
> Whis is about window functions, like
>
>    WITH q(a,b) AS (VALUES (1, 1), (1, 1), (2, 1))
>    SELECT *,
>           count(DISTINCT a) OVER (PARTITION BY b)
>    FROM q;
>
>    ERROR:  DISTINCT is not implemented for window functions
>    LINE 3:        count(DISTINCT a) OVER (PARTITION BY b)
>                   ^
>
> Yours,
> Laurenz Albe

Thanks a lot Laurenz, I got the issue now. I was looking at aggregation 
function without windowing.

I will revisit this again.


Thanks,

Ankit