You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I've noticed that queries with COUNT(*) OVER() aggregations return an error: mismatch rowid 1 != 2. An example of such a query is:
WITH Produce AS
(SELECT'kale'as item, 23as purchases, 'vegetable'as category
UNION ALLSELECT'banana', 2, 'fruit'UNION ALLSELECT'cabbage', 9, 'vegetable'UNION ALLSELECT'apple', 8, 'fruit'UNION ALLSELECT'leek', 2, 'vegetable'UNION ALLSELECT'lettuce', 10, 'vegetable')
SELECT item, purchases, COUNT(*) OVER () AS total_items
FROM Produce
If I run the same query in BigQuery it returns the following results:
item
purchases
total_items
kale
23
6
banana
2
6
cabbage
9
6
apple
8
6
leek
2
6
lettuce
10
6
I've noticed that the zetasql library transforms this query into the following:
I think the issue is that SQLite only callszetasqlite_window_count_star once for each row and produces a single row, whereas the desired behavior would be to create the same number of rows as the input data has. This is the behavior if the COUNT(*) OVER() aggregation is replaced with SUM(purchases) OVER(). I modified the query slightly to test the different behavior between BigQuery and SQLite:
@jeromefroe - I tested this in our fork (Recidiviz/bigquery-emulator) with #169 merged and it works as expected.
@goccy I've got little hope that my upstream feature in mattn/go-sqlite will be merged as its already been a year. Do you think you could comment on the issue expressing your support for it?
Hi, I've noticed that queries with
COUNT(*) OVER()
aggregations return an error:mismatch rowid 1 != 2
. An example of such a query is:If I run the same query in BigQuery it returns the following results:
I've noticed that the
zetasql
library transforms this query into the following:I think the issue is that SQLite only calls
zetasqlite_window_count_star
once for each row and produces a single row, whereas the desired behavior would be to create the same number of rows as the input data has. This is the behavior if theCOUNT(*) OVER()
aggregation is replaced withSUM(purchases) OVER()
. I modified the query slightly to test the different behavior between BigQuery and SQLite:On BigQuery this query returns 6 results, but SQLite only returns a single result.
The text was updated successfully, but these errors were encountered: