Skip to content
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

Changes to dispatch in dbt v0.20 #12

Closed
jtcohen6 opened this issue Jun 6, 2021 · 1 comment
Closed

Changes to dispatch in dbt v0.20 #12

jtcohen6 opened this issue Jun 6, 2021 · 1 comment

Comments

@jtcohen6
Copy link

jtcohen6 commented Jun 6, 2021

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.

{% macro fetch_configured_models(meta_config, models=none, resource_type="model") %}
{{ return(adapter.dispatch("fetch_configured_models", packages=dbt_meta_testing._get_meta_test_namespaces())(meta_config, models, resource_type)) }}
{% endmacro %}

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 expect dbt_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 for dbt_meta_test_dispatch_list IFF the dispatching package is dbt_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:

@tnightengale
Copy link
Owner

tnightengale commented Jul 17, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants