specql icon indicating copy to clipboard operation
specql copied to clipboard

Feature request: new option to add distinct / distinct on

Open mattiuusitalo opened this issue 1 year ago • 3 comments

Adding DISTINCT / DISTINCT on would be pretty useful, e.g.

SELECT DISTINCT ON (location) location, time, report
    FROM weather_reports
    ORDER BY location, time DESC;

I propose a new option :specql.core/distinct

  • If provided value is nil or key is not present, it will use SELECT ALL (current behaviour)
  • If value is empty seq, it will use DISTINCT
  • If value is a seq of columns, it will use DISTINCT ON

Willing to provide a PR

mattiuusitalo avatar Mar 09 '23 14:03 mattiuusitalo

Good feature, but I'm not sure about the empty seq parameter.

Perhaps it should be false (default) / true (distinct) / columns (distinct on).

Feels like empty seq could mask some bugs, but if there is a rationale for it.

tatut avatar Mar 09 '23 16:03 tatut

I like that. I had no specific reason to go for the empty seq. Just trying to figure out a value that signifies plain distinct across all columns.

mattiuusitalo avatar Mar 09 '23 18:03 mattiuusitalo

PR welcome

tatut avatar Mar 09 '23 18:03 tatut