Merge 'Aggregation without group by produces incorrect results for scalars' from Ihor Andrianov

Closes #954
Before:
<img width="669" alt="Знімок екрана 2025-03-27 о 21 49 19"
src="https://github.com/user-
attachments/assets/d005e690-7dab-41e5-bc03-b574cade3965" />
After:
<img width="676" alt="Знімок екрана 2025-03-27 о 21 49 44"
src="https://github.com/user-
attachments/assets/1f4eb6bf-a238-496e-9fa4-32382799ef86" />
SQLite:
<img width="656" alt="Знімок екрана 2025-03-27 о 21 50 04"
src="https://github.com/user-
attachments/assets/3eca184e-6ea5-47c1-824f-51d11256a7af" />

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1198
This commit is contained in:
Jussi Saurio
2025-04-06 20:00:30 +03:00
8 changed files with 338 additions and 72 deletions

View File

@@ -99,6 +99,27 @@ do_execsql_test select-agg-binary-unary-positive {
SELECT min(age) + +max(age) FROM users;
} {101}
do_execsql_test select-non-agg-cols-should-be-not-null {
SELECT id, first_name, sum(age) FROM users LIMIT 1;
} {1|Jamie|503960}
do_execsql_test select-with-group-by-and-agg-1 {
SELECT id, first_name, avg(age) FROM users group by last_name limit 1;
} {274|Debra|66.25}
do_execsql_test select-with-group-by-and-agg-2 {
select first_name, last_name from users where state = 'AL' group by last_name limit 10;
} {Jay|Acosta
Daniel|Adams
Aaron|Baker
Sharon|Becker
Kim|Berg
Donald|Bishop
Brian|Bradford
Jesus|Bradley
John|Brown
Hunter|Burke}
do_execsql_test select-agg-json-array {
SELECT json_group_array(name) FROM products;
} {["hat","cap","shirt","sweater","sweatshirt","shorts","jeans","sneakers","boots","coat","accessories"]}

0
testing/testing Normal file
View File