BigQuery: region-qualified INFORMATION_SCHEMA reference is rewritten across transpile passes, gaining an invented alias

Aperta
#9,104 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@ansh-rohilla ci sta già lavorando.

Dal 15/11/2026.

  • #9109 di @ansh-rohilla — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
28/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python, sql
Ambito
compilers

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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).

Lingua principale
Python
Stelle
9.8k
Fork
1.4k
Merge medio
13h 19m
PR unite (30g)
243

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tobymao/sqlglot

Tutte le issue di tobymao/sqlglot

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.