dbt-labs / dbt-labs/dbt

[v2 Bug] BigQuery docs generate fails: Fusion catalog macro uses db_schema.identifier as region

Open
#15,546 0 comments 0 reactions 0 assignees View on GitHub
triage
Dominant language
Rust
Stars
13.8k
Forks
2.6k
Avg merge
21h 31m
Merged PRs (30d)
56

Description

### Is this a new bug in dbt v2.x compared to the latest version of dbt 1.x?

- [x] I believe this is a new bug in dbt v2.x
- [x] I have searched the existing issues and could not find a duplicate

Related (same area, different symptoms): #15157, #13534, dbt-labs/dbt-adapters#1005

### Current Behavior

With `--use-v2-parser`, `dbt docs generate` fails during catalog generation with BigQuery errors like:

Unrecognized region: INFORMATION_SCHEMA

The generated SQL incorrectly joins TABLE_STORAGE via:

left join `my-project`.`region-INFORMATION_SCHEMA`.INFORMATION_SCHEMA.TABLE_STORAGE ...

instead of e.g. `my-project`.`region-us`.INFORMATION_SCHEMA.TABLE_STORAGE.

Root cause: the Fusion-embedded catalog macro in the v2 manifest uses:

{% set region = "region-%s"|format(db_schema.identifier) %}

`db_schema` is the information_schema relation passed to the catalog macro. In dbt's relation model, `.identifier` is always the literal string `INFORMATION_SCHEMA` (the view namespace) — see `InformationSchema.get_path()` in dbt-adapters, which hardcodes `identifier="INFORMATION_SCHEMA"`. The dataset location (`US`, `EU`, etc.) is stored separately on `.location` and should be resolved via `adapter.get_dataset_location()`, as the v1 `metadata.sql` macro already does:

{% set location = adapter.get_dataset_location(relations[0]) %}
{% set information_schema = relations[0].incorporate(location=location).information_schema("TABLE_STORAGE") %}

Using `.identifier` for the region produces `region-INFORMATION_SCHEMA`, which matches the failing SQL in logs:

left join `andhealth-prod`.`region-INFORMATION_SCHEMA`.INFORMATION_SCHEMA.TABLE_STORAGE ...

Source file:
https://github.com/dbt-labs/dbt-core/blob/main/crates/dbt-loader/src/dbt_macro_assets/dbt-bigquery/macros/catalog/catalog.sql

The v1 parser path is unaffected. It uses installed dbt-bigquery package macros with `__TABLES__` (no TABLE_STORAGE region join).

### Expected Behavior

`dbt docs generate --use-v2-parser` should generate catalog metadata successfully, using the dataset location (e.g. via `adapter.get_dataset_location()` as in dbt-bigquery metadata.sql).

### Steps To Reproduce

1. Any BigQuery dbt project with `location: US` (or other region) in profiles.
2. Run:

dbt parse --use-v2-parser --target prod
dbt docs generate --use-v2-parser --target prod

3. Observe catalog errors: `Unrecognized region: INFORMATION_SCHEMA`

To inspect the buggy macro in the manifest:

python -c "import json; m=json.load(open('target/manifest.json')); sql=m['macros']['macro.dbt_bigquery._bigquery__get_table_shards_sql']['macro_sql']; print('uses db_schema.identifier:', 'db_schema.identifier' in sql); print(sql[:500])"

### Relevant log output

Unrecognized region: INFORMATION_SCHEMA

Bad SQL includes: `project`.`region-INFORMATION_SCHEMA`.INFORMATION_SCHEMA.TABLE_STORAGE

### Environment

- OS: macOS
- dbt-core: 1.12.0b3
- dbt-core-experimental-parser: 2.0.0a4
- dbt-bigquery: 1.11.2b1 (also repro'd on 1.12.0rc1)
- Adapter: bigquery
- Also repro'd on: dbt-core 1.12.0b2, 1.12.0rc1, 1.12.0rc2 with experimental-parser 2.0.0a1 through a4

Note: `--use-v2-parser` was introduced in 1.12.0b2. Bug present in all tested alpha/rc releases. Not a regression within 1.12 betas; appears broken since the Aug 2025 Fusion catalog rewrite from `__TABLES__` to INFORMATION_SCHEMA.TABLES + TABLE_STORAGE.

### Which database adapter are you using?

- [x] bigquery

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.