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

[FYI] Changes to dispatch in dbt v0.20 #32

Closed
jtcohen6 opened this issue Jun 6, 2021 · 2 comments
Closed

[FYI] Changes to dispatch in dbt v0.20 #32

jtcohen6 opened this issue Jun 6, 2021 · 2 comments
Assignees
Labels
feature This is is requesting a new feature

Comments

@jtcohen6
Copy link

jtcohen6 commented Jun 6, 2021

Hi Alex & team! I wanted to give you a heads up about a change to dispatch functionality coming in the next version of dbt. Let me know if you have questions, I'm more than 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.

In practice, this just looks like switching each macro like:
https://github.com/Datavault-UK/dbtvault/blob/d15aeab5691056348c0ccafe4e4f153cc7e84710/macros/internal/alias_all.sql#L1-L5
To:

{%- macro alias_all(columns=none, prefix=none) -%}


    {{- adapter.dispatch('alias_all', 'dbtvault')(columns=columns, prefix=prefix) -}}


{%- endmacro %}

I hope this could be as simple as Find + Replace for packages = dbtvault.get_dbtvault_namespaces()'dbtvault'.

If you prefer more explicit syntax, you could also make this:

{%- macro alias_all(columns=none, prefix=none) -%}


    {{- adapter.dispatch(macro_name = 'alias_all', macro_namespace = 'dbtvault')(columns=columns, prefix=prefix) -}}


{%- endmacro %}

For the README

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

dispatch:
  - macro_namespace: dbtvault
    search_order: ['my_project', 'dbtvault']  # 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.
  • You've named your override var adapter_packages, rather than the convention of dbtvault_dispatch_list, so we don't have backwards compatibility for checking that variable in dbt v0.19.2 + v0.20.0 as of now. Do you know if folks are relying on this today? If so, we can add (hard-coded) logic to check a var named adapter_packages IFF the dispatching package is named dbtvault.

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:

@jtcohen6 jtcohen6 added the feature This is is requesting a new feature label Jun 6, 2021
@DVAlexHiggs
Copy link
Member

DVAlexHiggs commented Jun 6, 2021

Thank you @jtcohen6 Really appreciate your efforts to inform us of this. We will ensure these changes are included our next release

@DVAlexHiggs
Copy link
Member

Actioned and added in dbvault v0.7.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This is is requesting a new feature
Projects
None yet
Development

No branches or pull requests

2 participants