What happened?
Dear developer,
Hope this would be helpful.
prql version: 0.8.1
comments: The select clause affects the translation of append clause. It might be caused by internal optimization in prql compiler.
In the following example, we assume tb1 and tb2 have the same columns. We append tb2 to tb1, and select two new columns. However, inside generated sql query, it selects new columns first. 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
select [new_col1=c1*2,new_col2=c2/c3]
SQL output
WITH table_1 AS (
SELECT
c2,
c3,
c1
FROM
tb1
UNION
ALL
SELECT
*
FROM
tb2
)
SELECT
c1 * 2 AS new_col1,
c2 / c3 AS new_col2
FROM
table_1 AS table_0
Expected SQL output
WITH table_1 AS (
SELECT
*
FROM
tb1
UNION
ALL
SELECT
*
FROM
tb2
)
SELECT
c1 * 2 AS new_col1,
c2 / c3 AS new_col2
FROM
table_1 AS table_0
MVCE confirmation
Anything else?
No response
What happened?
Dear developer,
Hope this would be helpful.
prql version: 0.8.1
comments: The
selectclause affects the translation ofappendclause. It might be caused by internal optimization in prql compiler.In the following example, we assume
tb1andtb2have the same columns. We appendtb2totb1, and select two new columns. However, inside generated sql query, it selects new columns first. Then theunionoperation fails.error message from the database: "each UNION query must have the same number of columns"
PRQL input
SQL output
Expected SQL output
MVCE confirmation
Anything else?
No response