`append` twice with null columns leads to runtime Google BigQuery SQL error `UNION ALL has incompatible types`

Abierto
#5,349 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
google-cloud, rust, sql

Línea de trabajo

Start with the related issue #5341 and trace how PRQL lowers nested append operations for the BigQuery target. Reproduce the supplied PRQL input and inspect the generated SQL and relevant tests; the issue names no source files or tests. Done means the generated BigQuery SQL uses subqueries and CTEs so repeated appends with null columns run without incompatible UNION ALL types.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug
What happened?
  • Doing two append in Google BigQuery with null columns.
  • prqlc outputs a query that leads to runtime failure UNION ALL has incompatible types
PRQL input
prql target:sql.bigquery

from beers
select { name, price_per_l, alcohol_degree = null, brewing_date = null }
sort { +price_per_l }
take 2
append (
  from beers
  select { name, price_per_l = null, alcohol_degree, brewing_date = null }
  sort { -alcohol_degree }
  take 2
  append (
    from beers
    select { name, price_per_l = null, alcohol_degree = null, brewing_date }
    sort { -brewing_date }
    take 2
  )
)
SQL output
(
  SELECT
    name,
    price_per_l,
    NULL AS alcohol_degree,
    NULL AS brewing_date
  FROM
    beers
  ORDER BY
    price_per_l
  LIMIT
    2
)
UNION
ALL (
  SELECT
    name,
    NULL AS price_per_l,
    alcohol_degree,
    NULL AS brewing_date
  FROM
    beers
  ORDER BY
    alcohol_degree DESC
  LIMIT
    2
)
UNION
ALL (
  SELECT
    name,
    NULL AS price_per_l,
    NULL AS alcohol_degree,
    brewing_date
  FROM
    beers
  ORDER BY
    brewing_date DESC
  LIMIT
    2
)
Expected SQL output
WITH cte0 as (
  SELECT
    name,
    price_per_l
  FROM
    beers
  ORDER BY
    price_per_l
  LIMIT
    2
), cte1 as (
  SELECT
    name,
    alcohol_degree,
  FROM
    beers
  ORDER BY
    alcohol_degree DESC
  LIMIT
    2
), cte2 as (
  SELECT
    name,
    NULL AS price_per_l,
    NULL AS alcohol_degree,
    brewing_date
  FROM
    beers
  ORDER BY
    brewing_date DESC
  LIMIT
    2
)
(
  SELECT
    name,
    price_per_l,
    NULL AS alcohol_degree,
    NULL AS brewing_date
  FROM
    cte0
)
UNION
ALL (
  SELECT
    name,
    NULL AS price_per_l,
    alcohol_degree,
    NULL AS brewing_date
  FROM
    cte1
)
UNION
ALL (
  SELECT
    name,
    NULL AS price_per_l,
    NULL AS alcohol_degree,
    brewing_date
  FROM
    cte2
)
MVCE confirmation
  • Minimal example
  • New issue
Anything else?

Related to https://github.com/PRQL/prql/issues/5341.
Unfortunately, Google BigQuery is even more picky, and needs both subqueries and CTEs to succesfully infer the types here.

Lenguaje dominante
Rust
Estrellas
10.9k
Forks
261
Merge medio
3 d 21 h
PR fusionados (30 d)
84

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PRQL/prql

Todos los issues de PRQL/prql

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.