-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[Bug] Microbatch: Calling ref() in a macro with a microbatch model name results in error #10928
Comments
Thanks for reporting this @brian-franklin ! I couldn't reproduce the error you got. Could you try the following and see if it works for you or not? Project files and commandsCreate these files:
{{
config(
materialized='incremental',
incremental_strategy='microbatch',
event_time='landed_timestamp',
begin='2023-01-01',
batch_size='day',
on_schema_change='append_new_columns',
schema='inscape',
tags=["inscape"]
)
}}
select 1 as id
{% macro test_ref_microbatch(node) %}
{{ log('Running for node: ' ~ node, info=True) }}
{% set relation=ref(node) %}
{{ log('relation: ' ~ relation, info=True) }}
{% endmacro %} Run this command: dbt run-operation test_ref_microbatch --args '{node: model_name}' Log output:
|
@dbeatty10 I tried this and it worked, however, I realize I left out an aspect of my project setup that I now see it causing the issue. I am using an environment variable to set the database name. Here is a representative example of the section project yaml dbt_project yaml
I am using a setting.json file to set the environment variable... settings.json file
Now when I run the macro, I am able to reproduce the error... Log Output
|
Ah, I see what you are saying @brian-franklin 👍 All I needed to do to reproduce this was to start with #10928 (comment) and then set the Here's the place in the code where the error is triggered: dbt-core/core/dbt/context/providers.py Line 244 in 8df5c96
|
Should be a matter of more safely determining whether to resolve an event_time_filter. We should only be doing this for microbatch models, so an isinstance(self.model, ModelNode) should suffice there: https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/context/providers.py#L244C22-L244C27 |
Is this a new bug in dbt-core?
Current Behavior
When running a macro that executes ref() with a microbatch model name, an error occurs:
'Macro' object has no attribute 'config'
Expected Behavior
ref() should resolve to a relation with the 3-part name of the object.
Steps To Reproduce
dbt run-operation test_ref_microbatch --args '{node: model_name}'
Relevant log output
Environment
Which database adapter are you using with dbt?
snowflake
Additional Context
Here is my microbatch model config:
The text was updated successfully, but these errors were encountered: