Changes to dispatch in dbt v0.20
jtcohen6 opened this issue · 1 comments
Hey Teghan! I wanted to give you a heads up about a change coming in the next version of dbt. Let me know if you have questions, I'm happy to help.
Required code change
We've made a change to adapter.dispatch
: Instead of passing a _get_namespaces()
macro to the packages
arg, you should pass the name of this package (as a string) to the macro_namespace
arg, which is now the second positional argument.
dbt-meta-testing/macros/fetch_configured_models.sql
Lines 1 to 3 in cd1cb2b
To:
{% macro fetch_configured_models(meta_config, models=none, resource_type="model") %}
{{ return(adapter.dispatch("fetch_configured_models", "dbt_meta_testing")(meta_config, models, resource_type)) }}
{% endmacro %}
I hope this could be as simple as Find + Replace for packages=dbt_meta_testing._get_meta_test_namespaces()
→ "dbt_meta_testing"
.
If you prefer more explicit syntax, you could also make this:
{% macro fetch_configured_models(meta_config, models=none, resource_type="model") %}
{{ return(adapter.dispatch(macro_name = "fetch_configured_models", macro_namespace = "dbt_meta_testing")(meta_config, models, resource_type)) }}
{% endmacro %}
For the README
If a user wishes to override/shim this package, instead of defining a var named dbt_meta_test_dispatch_list
, they should now define a config in dbt_project.yml
, for instance:
dispatch:
- macro_namespace: dbt_meta_testing
search_order: ['my_project', 'dbt_meta_testing'] # enable override
Notes
This change is in dbt v0.19.2 as well. Both v0.19.2 and v0.20.0 have backwards compatibility for the old syntax, so there's no huge rush to upgrade.
However:
- The old syntax will start raising a deprecation warning in v0.20
- The var name in this package,
dbt_meta_test_dispatch_list
, varies just slightly from the convention established by other packages. The backwards-compatibility logic we added to dbt would instead expectdbt_meta_testing_dispatch_list
. If you know other folks are relying on this functionality to override/shim this package, we can hard code logic that looks fordbt_meta_test_dispatch_list
IFF the dispatching package isdbt_meta_testing
.
As soon as you do upgrade to the new syntax, you'll need to require dbt >= 0.19.2
(or just >=0.20.0
, for simplicity, since you're already making compatibility changes in #69).
See also:
Handled in 0.3.3.
@jtcohen6 thank you so much for raising this with such detail! Hope all is well and congratulations on the amazing series C! #dbtforever