-
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
[CT-1090] [Bug] dbt.type_timestamp() is not working using dbt 1.2.1 #5720
Comments
In order to reproduce this:
Why generic tests? For parsing speed, dbt constructs slimmer rendering contexts when parsing generic tests. It attempts to include just the macros that are called (depended on by) the generic test definition... and any macros those macros depend on, and so on. The If the package is installed, for whatever reason, dbt is resolving In any case, it's possible to avoid this error by:
In an ideal world, our macro dispatching/resolution order wouldn't yield this surprising outcome! I think the code involved here is pretty gnarly. IIRC it's around here: dbt-core/core/dbt/context/macros.py Lines 128 to 148 in 5f59ff1
Workaround: Never use a In a weird way, this issue (in its narrowest sense) will be fixed when |
Taking another look here, since we might want to consider recommending Repro case-- macros/some_test.sql
{% test some_test(model) %}
select cast(current_timestamp as {{ dbt.type_timestamp() }})
limit 0
{% endtest %} -- models/some_model.sql
select 1 as id # models/config.yml
version: 2
models:
- name: my_model
tests:
- some_test # packages.yml
packages:
- package: dbt-labs/dbt_utils
version: 0.9.2
# note that removing this, removes the bug!
Big idea, restatedWe build a special context for generic test parsing that contains only the macros we think are necessary. That happens in these funky methods: dbt-core/core/dbt/context/providers.py Lines 1530 to 1552 in 49ecd6a
dbt-core/core/dbt/context/macro_resolver.py Lines 130 to 173 in 49ecd6a
The problem: When This is the spot where we're saying that dbt-core/core/dbt/parser/manifest.py Line 539 in 49ecd6a
Why? Because our macro resolution logic, which has special logic in case a specific package namespace has been specified, does not use said logic if the specified package namespace is an "internal" namespace ( dbt-core/core/dbt/context/macro_resolver.py Lines 110 to 120 in 49ecd6a
Precise fix: Add logic to The precise fix could maybe be a breaking change for people who have been depending on funky/undocumented behavior around resolution order for global macros — namely, that my root project's |
Is this a new bug in dbt-core?
Current Behavior
Using dbt.type_timestamp() I get,
dict object' has no attribute 'type_timestamp
but it works using
type_timestamp()
.dbt.<macro>()
works for others though.Expected Behavior
I expected
dbt.type_timestamp()
to work flawlessly :smiSteps To Reproduce
Using 1.2.1, try
Relevant log output
Environment
Which database adapter are you using with dbt?
postgres, snowflake, bigquery
Additional Context
No response
The text was updated successfully, but these errors were encountered: