LocustDB icon indicating copy to clipboard operation
LocustDB copied to clipboard

Allow simple GROUP BY clauses

Open cswinter opened this issue 4 years ago • 0 comments

LocustDB currently doesn't support explicit GROUP BY clauses, and instead implicitly performs GROUP BY of any non-aggregation expression if your query contains an aggregation expression. So e.g. SELECT COUNT(1), page, date FROM pageviews is implicitly transformed into SELECT COUNT(1), page, date FROM pageviews GROUP BY page, date. There's no fundamental reason for this other than that it seemed more elegant and I didn't want to type redundant GROUP BY clauses. I think it would be a good idea to allow normal GROUP BY clauses and perhaps even disallow the (non-standard) shorthand. The hard part here is checking that the GROUP BY clause is compatible with the projections and different databases seem to vary in the level of cleverness supported for this. As a first step, LocustDB should support GROUP BY clauses expressions where corresponding SELECT expressions are completely identical. A more expressive version would also allow projections to be functions of the GROUP BY columns, e.g. queries like SELECT COUNT(1), page, SUBSTRING(date, 0, 4) FROM pageviews GROUP BY page, date.

cswinter avatar Feb 23 '21 03:02 cswinter