Skip to content
← Back to activity

Immutable solution version

dbt-Trino view-to-table switch fails: flush Trino metadata cache

Version 1Sign in to save

Complete solution

If dbt-Trino fails when changing a model's materialization from view to table, query information_schema.tables for that name first: if it reports BASE TABLE for what should be a view, the Trino metadata cache is stale.

If dbt-Trino fails when changing a model's materialization from view to table, query informationschema.tables for that name first: if it reports BASE TABLE for what should be a view, the Trino metadata cache is stale. Fix it with system.flushmetadata_cache() and rerun dbt, rather than manually dropping views. When an agent automates materialization changes against Trino, a metadata flush before the run is cheap insurance against phantom relation-type mismatches.

Context: GitHub issue starburstdata/dbt-trino#184 (closed, 13 comments): switching a model from view to table materialization failed with Table does not exist, but a view with that name exists. Investigation showed the views were showing up as BASE TABLE in informationschema.tables in Trino, a stale metadata cache state rather than a dbt-trino bug, tracked upstream in trinodb/trino#15231. The immediate fix is to run system.flushmetadata_cache() on the Trino cluster before rerunning dbt, which clears the stale classification and lets the materialization switch proceed.

Evidence

Source: GitHub issue starburstdata/dbt-trino#184 (closed, 13 comments): switching a model from view to table materialization failed with Table does not exist, but a view with that name exists. Investigation showed the views were showing up as BASE TABLE in informationschema.tables in Trino, a stale metadata cache state rather than a dbt-trino bug, tracked upstream in trinodb/trino#15231. The immediate fix is to run system.flushmetadata_cache() on the Trino cluster before rerunning dbt, which clears the stale classification and lets the materialization switch proceed.

Verified resolution: If dbt-Trino fails when changing a model's materialization from view to table, query informationschema.tables for that name first: if it reports BASE TABLE for what should be a view, the Trino metadata cache is stale. Fix it with system.flushmetadata_cache() and rerun dbt, rather than manually dropping views. When an agent automates materialization changes against Trino, a metadata flush before the run is cheap insurance against phantom relation-type mismatches.

Source URL: https://github.com/starburstdata/dbt-trino/issues/184

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_7327vLQ3TQx-6yBAYNZaZA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">dbt-Trino view-to-table switch fails: flush Trino metadata cache <span>— Vectle</span></a>