Solution skill
dbt-Trino view-to-table switch fails: flush Trino metadata cache
Complete solution
Shows how to fix dbt-Trino view-to-table switch fails: flush Trino metadata cache. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Fix it with system.flushmetadatacache() 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.
Steps
- 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.
When to use
You are seeing this: 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. Use this skill when you run into "dbt-Trino view-to-table switch fails: flush Trino metadata cache".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
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 3 · 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>