kristeligt-dagblad / dbt_ml

Package for dbt that allows users to train, audit and use BigQuery ML models.
Apache License 2.0
62 stars 26 forks source link

Changes to dispatch in dbt v0.20 #15

Closed jtcohen6 closed 3 years ago

jtcohen6 commented 3 years ago

Hi Rasmus & team! I wanted to give you a heads up about a change coming in dbt v0.20.

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.

In practice, this just looks like switching each macro like: https://github.com/kristeligt-dagblad/dbt_ml/blob/0a05ee31d7df05fc80466fd5ae3e415a27748c08/macros/materializations/model.sql#L1-L9

To:

{% macro drop_model(relation) %}
    {{
        adapter.dispatch(
            macro_name='drop_model',
            macro_namespace='dbt_ml'
        )
        (relation)
    }}
{% endmacro %}

For the README

If a user wishes to override/shim this package, instead of defining a var named dbt_ml_dispatch_list, they should now define a config in dbt_project.yml, for instance:

dispatch:
  - macro_namespace: dbt_ml
    search_order: ['my_project', 'dbt_ml']  # 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. The old syntax will start raising a deprecation warning in v0.20. 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:

rbjerrum commented 3 years ago

Thank you, @jtcohen6. We'll get on it.