-
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-112] Better UX for macro dispatch #4646
Comments
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue, or it will be closed in 7 days. |
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest; add a comment to notify the maintainers. |
I'm going to un-stale this, I'd still like to do it someday :) |
Following this thread - some Footnotes
|
You raise a great point. Virtually all of my PRs to dbt-core are to do exactly this. However, we don't normally see a need for this macro to be overridden, as there's not actually SQL code in there.
|
TL;DR: All macros should be dispatch for the sake of consistency - I think this makes it "better UX". @dataders - My 2c is that it's irrelevant what the use-case is for wanting to override a I shared this internally:
Yea 100%. In this scenario, a team leader wants to write a "shared_lib" with overriden "core macros" like Now as the end user of the "shared_lib" package, one has to remember that... "oh for So at the end of it all, I think all core macros should have the same pattern wrt overriding them in root projects without needing to think of when you'd need to also add some dispatching code in your root project. Although Jerco has mentioned "special kinds of macros" - so perhaps differentiating between macros that are dispatched and not dispatched by default is appropriate? I'm not sure what category to put this |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers. |
Big idea
We're moving, slowly but surely, in the direction of sensible defaults for macro dispatch. Now that we've established conventions, let's find ways to make it easier/quicker to write.
Take
dbt_utils.hash
for example. This has to include a lot of supporting code to do something that's ultimately pretty simple:What are the problems here?
default__
adapter decorator is unintuitive for folks who are looking to take advantage of dispatch's package override capabilities, and who might be unfamiliar with its history as (primarily) a way to support cross-database macrosImagine the same macro, like:
The implied (default) behavior is that a macro named
hash
, in the package nameddbt_utils
:hash
in thedbt_utils
namespacedefault__
implementation ofhash
The prime beneficiaries of this change would be package maintainers (+ us, as
global_project
maintainers).There's two additional considerations we need to make, for "special kinds of macros": materializations and generic tests.
Materializations
Adapter-specific materializations work differently from adapter-specific macros. Namely:
{% materialization table, adapter = 'snowflake' %}
creates a macro namedmaterialization_table_snowflake
, rather than (as one would expect)snowflake__materialization_table
Could we make materialization macro generation / discovery work more like dispatch? We'd need to offer backwards compatibility / avoiding breaking changes for folks who currently rely on the
materialization_<name>_<adapter>
construction.One other thing: I actually like the syntax for defining adapter-specific materializations. (It's important to have the
adapter__
-prefixed version available, in order to call from other macros.) As part of that reconciliation, could we support this for other macros, too? Same example as above:Better, no?
And then even:
Generic tests
Tests aren't dispatch-able at all today, so it's necessary to do something like:
If we pursue either/both of the ideas presented above, I think we'd be in good shape for tests, too:
bigquery__test_at_least_one
should "just work"{% test at_least_one(model, column_name), adapter = 'bigquery' %}
The text was updated successfully, but these errors were encountered: