BigQuery: region-qualified INFORMATION_SCHEMA reference is rewritten across transpile passes, gaining an invented alias
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 28/100
調査の方向性
Run the two-pass snippet from the issue to confirm the drift, then read the BigQuery dialect in sqlglot/dialects/bigquery.py, where INFORMATION_SCHEMA table parts are parsed and the alias/quoting is generated; the related history in #4336 explains the single-identifier preference. The example comes from tests/dialects/test_bigquery.py, so add a fixed-point assertion there. Done means applying transpile twice leaves region_or_dataset.INFORMATION_SCHEMA.TABLES unchanged, with no invented AS TABLES alias and no whole-path quoting.
索引モデルが issue の本文から書いたものです。
説明
Fully reproducible code snippet
import sqlglot
s = "SELECT * FROM region_or_dataset.INFORMATION_SCHEMA.TABLES"
g1 = sqlglot.transpile(s, read="bigquery", write="bigquery")[0]
# 'SELECT * FROM region_or_dataset.`INFORMATION_SCHEMA.TABLES` AS TABLES'
g2 = sqlglot.transpile(g1, read="bigquery", write="bigquery")[0]
# 'SELECT * FROM `region_or_dataset.INFORMATION_SCHEMA.TABLES` AS TABLES'
The input is taken from sqlglot's own BigQuery tests.
Expected
A multi-part table path round-trips as the same table path, with no alias added.
Actual
The first generation quotes INFORMATION_SCHEMA.TABLES as a single identifier and invents an AS TABLES alias that is not in the source. The second generation quotes the entire dotted path as one identifier, changing the reference's meaning (one name containing dots instead of separate parts). It converges at g2, but at the wrong value. Related history: #4336 made the parser favour a single identifier for INFORMATION_SCHEMA.X, which makes the hybrid first-pass form, and the drift between passes, the inconsistency.
Checked against main at commit b294f7f.
Official Documentation
BigQuery INFORMATION_SCHEMA (including region qualifiers): https://cloud.google.com/bigquery/docs/information-schema-intro
Found by property-based testing (a round-trip fixed-point property over sqlglot's own test corpus).
- 主要言語
- Python
- スター
- 9.8k
- フォーク
- 1.4k
- 平均マージ
- 13時間 19分
- マージ済み PR(30日)
- 243
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
tobymao/sqlglot のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
SQLite: CAST(x AS JSON) is generated verbatim, which SQLite evaluates as a numeric cast対応中かも @Gowthamsuryagolla が今日担当しました。 オープン
難易度 3/5 半日 初心者へのやさしさ 32/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
メンテナーはふだん 1 日以内に返信
-
Optimizer drops parentheses for `NOT (<date> = DATE_TRUNC(...))`, changing query results対応中かも @parthdembla007 が今日担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 28/100
メンテナーはふだん 1 日以内に返信
-
DATE_ADD/DATE_SUB with a single argument raises AttributeError (BigQuery, MySQL, Doris, StarRocks)対応中かも @akchhayasharma が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 42/100
メンテナーはふだん 1 日以内に返信
tobymao/sqlglot の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
alltheplaces/alltheplaces#20570 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
area:ci bug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
catincloud-labs/dagster-dex#206 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
number_to_words raises ValueError with threshold= for ordinals ("12th") and comma-grouped strings ("1,000")対応中かも @hemtilva が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
providers security
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
agentbreeder/agentbreeder#1031 ·
メンテナーはふだん 1 日以内に返信