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
{{ message }}
Repository navigation
append twice with null columns leads to runtime Google BigQuery SQL error UNION ALL has incompatible types #5349
(
SELECT
name,
price_per_l,
NULLAS alcohol_degree,
NULLAS brewing_date
FROM
beers
ORDER BY
price_per_l
LIMIT2
)
UNION
ALL (
SELECT
name,
NULLAS price_per_l,
alcohol_degree,
NULLAS brewing_date
FROM
beers
ORDER BY
alcohol_degree DESCLIMIT2
)
UNION
ALL (
SELECT
name,
NULLAS price_per_l,
NULLAS alcohol_degree,
brewing_date
FROM
beers
ORDER BY
brewing_date DESCLIMIT2
)
Expected SQL output
WITH cte0 as (
SELECT
name,
price_per_l
FROM
beers
ORDER BY
price_per_l
LIMIT2
), cte1 as (
SELECT
name,
alcohol_degree,
FROM
beers
ORDER BY
alcohol_degree DESCLIMIT2
), cte2 as (
SELECT
name,
NULLAS price_per_l,
NULLAS alcohol_degree,
brewing_date
FROM
beers
ORDER BY
brewing_date DESCLIMIT2
)
(
SELECT
name,
price_per_l,
NULLAS alcohol_degree,
NULLAS brewing_date
FROM
cte0
)
UNION
ALL (
SELECT
name,
NULLAS price_per_l,
alcohol_degree,
NULLAS brewing_date
FROM
cte1
)
UNION
ALL (
SELECT
name,
NULLAS price_per_l,
NULLAS alcohol_degree,
brewing_date
FROM
cte2
)
MVCE confirmation
Minimal example
New issue
Anything else?
Related to #5341.
Unfortunately, Google BigQuery is even more picky, and needs both subqueries and CTEs to succesfully infer the types here.
Activity