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
Maybe my intuition regarding this is lacking but with this query:
from alb = albums
join t = tracks [t.album_id==alb.album_id]
join art = artists [art.artist_id==alb.artist_id]
# Songs shorter than 4 minutes
filter t.milliseconds < 4 * 60 * 1000
group [alb.album_id] (
take 1
)
take 10
I expect the result to have just one row per album but that is not what happens as of version 0.5.0. The resulting sql have SELECT DISTINCT on all columns:
WITH table_1 AS (
SELECT
DISTINCT alb.*,
t.*,
art.*FROM
albums AS alb
JOIN tracks AS t ONt.album_id=alb.album_idJOIN artists AS art ONart.artist_id=alb.artist_idWHEREt.milliseconds<240000
)
SELECT*,
*,
*FROM
table_1
LIMIT10-- Generated by PRQL compiler version:0.5.0 (https://prql-lang.org)
In contrast
If I add a sort transform inside the group I get a reasonable result (but I don't think I should have to sort to get the behavior that I'm after):
from alb = albums
join t = tracks [t.album_id==alb.album_id]
join art = artists [art.artist_id==alb.artist_id]
# Songs shorter than 4 minutes
filter t.milliseconds < 4 * 60 * 1000
group [alb.album_id] (
sort alb.album_id
take 1
)
take 10
Similar query, but with aggregation also behaves as expected:
from alb = albums
join t = tracks [t.album_id==alb.album_id]
join art = artists [art.artist_id==alb.artist_id]
# Songs shorter than 4 minutes
filter t.milliseconds < 4 * 60 * 1000
group [alb.album_id] (
aggregate [
number_tracks = count
]
)
take 10
The text was updated successfully, but these errors were encountered:
Maybe related to #1748
The problem
Maybe my intuition regarding this is lacking but with this query:
I expect the result to have just one row per album but that is not what happens as of version 0.5.0. The resulting sql have
SELECT DISTINCT
on all columns:In contrast
If I add a
sort
transform inside thegroup
I get a reasonable result (but I don't think I should have to sort to get the behavior that I'm after):Similar query, but with aggregation also behaves as expected:
The text was updated successfully, but these errors were encountered: