calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aman Sinha <amansi...@apache.org>
Subject DISTINCT ON clause
Date Wed, 21 Feb 2018 20:44:35 GMT
The DISTINCT 'ON' clause is not supported but I am trying to see if there
are other people who have run into this.  One of the use cases I have
intuitively maps to something like this:

  SELECT DISTINCT *ON (a)*,  b, c  FROM T

Here  suppose 'a' is an INT  and b, c are some complex types such as
array.  In my example, the values of  b and c happen to be the same in all
rows belonging to the same group of 'a', so I just want the first row.
Since these are arrays, I cannot use MIN(b) GROUP BY a .   Other
alternative is to create a new aggregate function that picks the first
value but it makes the syntax verbose especially with large number of such
columns.

Incidentally, Postgres supports this [1]

[1]
https://www.postgresql.org/docs/current/static/sql-select.html#SQL-DISTINCT


-Aman

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message