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

オープン
#5,349 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
google-cloud, rust, sql
領域
backend, databases

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Rust
スター
10.9k
フォーク
261
平均マージ
3日 20時間
マージ済み PR(30日)
85

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PRQL/prql のほかの issue

PRQL/prql の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。