-
Notifications
You must be signed in to change notification settings - Fork 186
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
[Feature] Allow snowflake__get_relation_last_modified to references models or sources #1054
Comments
Just to add context to this--in the case where we might want to ref() a model for freshness results, I dont really expect dbt to know it should run the model that I'm using to track freshness before the freshness tests. We just have a step in our process that executes the model first, and then our freshness tests are executed in a subsequent step. |
I'd say this is quite important context! The reason being that, today, we don't support freshness checks on External Tables. This might be something we support in the future, especially given that we're beginning the design work to make External Tables first-class citizens in dbt (dbt-labs/dbt-adapters#92). If you have a way to implement freshness checks on External Tables, I'd love to see it! Perhaps it could be written up as an enhancement issue for the dbt-external-tables package. I have to say, we did not anticipate users wanting to override the |
@sp-tkerlavage I'm also now seeing your comments on #785: #785 (comment) & #785 (comment) Given that context, I think it's worth saying that your end-goal is that you'd like the following:
I see two ways that dbt could this scenario:
The issue that you've highlighted here is that you encountered an error while attempting to implement (1) yourself by overriding the I think the real next step is that we have the discussion about (1) in #1061 (that I just created). Accordingly, I'm going to close this issue in favor of that one. In that issue, we can spell out the exact use case and gauge the priority of supporting the feature request. Perhaps during this discovery work we discover an alternative workaround to get you what you need. |
Edit looks like we commented right around the same time! Can most likely ignore the below as its essentially just restated. Yes I was able to get freshness tests working for external tables in my project. I use Snowflake's DIRECTORY tables which is an optional object on a Snowflake External Stage. Looks like I outlined the details here: The query to determine freshness would likely be different for everyones implementation. In my case for simplicity I have a single main external stage that has the directory enabled. The bucket itself is structured like: |
@sp-tkerlavage thanks for all the context! I'm going to close this issue in support of #1061, which is the actual desired end state. But everything you've shared here will be helpful if we decide to implement. |
Thank you! |
Is this your first time submitting a feature request?
Describe the feature
Not sure if this is a bug or expected behavior, so suggesting this as a feature.
Not so important context: I have an edge case where I need to track the freshness of external tables. I think the modified_at in the snowflake information_schema for external tables is not reliable. It tells you when the external table itself was last modified by a refresh of DDL. This is often not the same as when the last file actually came into the external source. So I have a custom model that I use to track the freshness of the external table based on the actual files in the S3 bucket.
Currently if you override the
snowflake__get_relation_last_modified
macro with a custom implementation that relies on a {{source()}} you get the following warning:You can easily reproduce this by just tweaking the current implementation of the macro to use a source
You will get a similar error if you use a ref as well:
Describe alternatives you've considered
A simple workaround is to just hardcode the name of the table that I want to use as the base of my freshness test. This works fine.
I only discovered this issue when I checked if batch freshness would work and found that it did not because the snowflake__get_relation_last_modified macro I had was referencing a model using ref()
Who will this benefit?
Anyone that overrides the snowflake__get_relation_last_modified macro to drive a custom implementation of freshness tests.
Are you interested in contributing this feature?
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: