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
This issue is similar to an existing one, #2680. But I'm not sure if the root causes of those two issues are the same. So I open a new one.
I found that the aggregate clause also affects the translation of the append clause.
In the following example, assuming tb1 and tb2 have the same columns, we append tb2 to tb1, and get the minimum c0. But in the SQL code, it selects the target column before the union operation. Then the union operation fails.
error message from the database: "each UNION query must have the same number of columns"
PRQL input
from tb1
append tb2
aggregate {new_col1 = min c0}
SQL output
WITH table_0 AS (
SELECT
c0
FROM
tb1
UNION
ALL
SELECT*FROM
tb2
)
SELECTMIN(c0) AS new_col1
FROM
table_0
-- Generated by PRQL compiler version:0.9.2 (https://prql-lang.org)
Expected SQL output
WITH table_0 AS (
SELECT
c0
FROM
tb1
UNION
ALL
SELECT
c0
FROM
tb2
)
SELECTMIN(c0) AS new_col1
FROM
table_0
Yes. I have spent less time on the append-like table operations, so I'll defer to others.
I note that writing it out more explicitly works:
let x =(
from tb2
select c0
)from tb1
select c0
append x
WITH x AS (
SELECT
c0
FROM
tb2
)
SELECT
c0
FROM
tb1
UNION
ALL
SELECT*FROM
x
-- Generated by PRQL compiler version:0.9.2 (https://prql-lang.org)
Though we have quite poor error messages (which also don't show in the playground) if anything is forgotten:
let x =(
from tb2
select c0
)from tb1
# select c0
append x
Activity
max-sixty commentedon Jul 31, 2023
Yes. I have spent less time on the
append-like table operations, so I'll defer to others.I note that writing it out more explicitly works:
Though we have quite poor error messages (which also don't show in the playground) if anything is forgotten:
richb-hanover commentedon Feb 4, 2024
I think this can be closed: compiler version 0.11.1 gives exactly this SQL output