-
Notifications
You must be signed in to change notification settings - Fork 503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_relations_by_prefix not working with snowflake external table #350
Comments
The issue here is that dbt supports a relation type called In fact, there's some logic in Snowflake's adapter cache such to handle exactly this error, and infer the type as It's a bit weird to see this cropping up in v0.19.1 for the very first time, though it makes sense: as part of core performance improvements, we've been much stricter about type checking internal objects, so I'm guessing that's the cause. Suffice to say, this ought to have been a type error in earlier versions, too. I'm hopeful that the resolution is as simple as extending the logic already here: To also read: case table_type
when 'BASE TABLE' then 'table'
when 'EXTERNAL TABLE' then 'external'
else lower(table_type)
end as "table_type" |
First, thank you for walking through the explanation. That makes a ton of sense. Second, I went into the file and adding the line for external table as you recommended. I can confirm that it did compile the model. {% set raw_tables = dbt_utils.get_relations_by_prefix(
database = 'raw',
schema = 'external_mra',
prefix = 'ASC_RATES_'
) %}
WITH combine AS (--
{% for table in raw_tables %}
SELECT
*
FROM
{{ table }}
{{ "UNION ALL" if not loop.last }}
{% endfor %})
SELECT
*
FROM
combine I assume that it'll be easier for you to create a pr because I'd have to become familiar with the |
I'd love if you could contribute the fix for this! The process looks like fork, change, commit, open PR :) We have CI tests that run on all PRs from forks, though (clearly) the CI tests weren't catching this because we don't have external tables in a schema pointed to by |
Created pr: pr url |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers. |
Describe the bug
I am working on updating from 0.6.2 to 0.6.4 so that we can update dbt version from 0.18.1 to 0.19.1. I am getting an error when compiling a model that
get_relations_by_prefix
and the tables in the schema are external tables in snowflake.Steps to reproduce
In the model:
{% set raw_tables = dbt_utils.get_relations_by_prefix( database = 'raw', schema = 'external_mra', prefix = 'ASC_RATES_' ) %}
dbt: 0.19.1
dbt-utils: 0.6.4
presently works on
dbt: 0.18.1
dbt-utils 0.6.2
cli:
dbt compile -m <model>
Expected results
that variable can then be used in this portion of the model
Screenshots and log output
error message
System information
packages.yml
Which database are you using dbt with?
The output of
dbt --version
:dbt version
Are you interested in contributing the fix?
I am up for learning and helping how I can
The text was updated successfully, but these errors were encountered: