mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-18 22:45:10 +01:00
Merge 'Add support for DISTINCT aggregate functions' from Jussi Saurio
Reviewable commit by commit. CI failures are not related. Adds support for e.g. `select first_name, sum(distinct age), count(distinct age), avg(distinct age) from users group by 1` Implementation details: - Creates an ephemeral index per distinct aggregate, and jumps over the accumulation step if a duplicate is found Closes #1507
This commit is contained in:
@@ -127,3 +127,7 @@ do_execsql_test select-agg-json-array {
|
||||
do_execsql_test select-agg-json-array-object {
|
||||
SELECT json_group_array(json_object('name', name)) FROM products;
|
||||
} {[{"name":"hat"},{"name":"cap"},{"name":"shirt"},{"name":"sweater"},{"name":"sweatshirt"},{"name":"shorts"},{"name":"jeans"},{"name":"sneakers"},{"name":"boots"},{"name":"coat"},{"name":"accessories"}]}
|
||||
|
||||
do_execsql_test select-distinct-agg-functions {
|
||||
SELECT sum(distinct age), count(distinct age), avg(distinct age) FROM users;
|
||||
} {5050|100|50.5}
|
||||
@@ -197,4 +197,13 @@ do_execsql_test group_by_no_sorting_required {
|
||||
select age, count(1) from users group by age limit 3;
|
||||
} {1|112
|
||||
2|113
|
||||
3|97}
|
||||
3|97}
|
||||
|
||||
do_execsql_test distinct_agg_functions {
|
||||
select first_name, sum(distinct age), count(distinct age), avg(distinct age)
|
||||
from users
|
||||
group by 1
|
||||
limit 3;
|
||||
} {Aaron|1769|33|53.6060606060606
|
||||
Abigail|833|15|55.5333333333333
|
||||
Adam|1517|30|50.5666666666667}
|
||||
Reference in New Issue
Block a user