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

Restore dbt. prefix for all migrated cross-db macros #690

Closed
joellabes opened this issue Sep 28, 2022 · 3 comments · Fixed by #701
Closed

Restore dbt. prefix for all migrated cross-db macros #690

joellabes opened this issue Sep 28, 2022 · 3 comments · Fixed by #701
Labels
bug Something isn't working good first issue

Comments

@joellabes
Copy link
Contributor

Describe the bug

In dbt-labs/dbt-core#5888, we discovered that dbt projects that already contained a macro with the same name (e.g. concat()) as a cross-db macro were taking precedence in an unexpected manner.

We want to switch back to explicitly stating the namespace (i.e. dbt.concat()) so that the dispatch logic works correctly (dbt-labs/dbt-core#5720 and dbt-labs/dbt-core#5907).

Additional context

The current best way I've come up with to handle this is a regex find and replace, using the list of cross-db macros from the docs site:

(any_value|bool_or|cast_bool_to_text|concat|dateadd|datediff|date_trunc|escape_single_quotes|except|hash|intersect|last_day|length|listagg|position|replace|right|safe_cast|split_part|string_literal|type_bigint|type_float|type_int|type_numeric|type_string|type_timestamp|type_bigint|type_float|type_int|type_numeric|type_string|type_timestamp|except|intersect|concat|hash|length|position|replace|right|split_part|escape_single_quotes|string_literal|any_value|bool_or|listagg|cast_bool_to_text|safe_cast|dateadd|datediff|date_trunc|last_day)

Replacing {1} with dbt.{1} (I only know one trick, but it's a good trick)

@jtcohen6: given that dbt-labs/dbt-core#5907 is v1.3 only, should this change be made available to both dbt-utils 0.9.x (requires dbt Core 1.2+) and dbt-utils 1.0 (requires dbt Core 1.3+) or only the latter? Do you have a read on which approach will be safer?

Are you interested in contributing the fix?

I'd love to see a community contribution here - happy to help out if the specifics wind up being gnarly.

@joellabes joellabes added bug Something isn't working good first issue labels Sep 28, 2022
@jtcohen6
Copy link
Contributor

jtcohen6 commented Sep 28, 2022

@jtcohen6: given that dbt-labs/dbt-core#5907 is v1.3 only, should this change be made available to both dbt-utils 0.9.x (requires dbt Core 1.2+) and dbt-utils 1.0 (requires dbt Core 1.3+) or only the latter? Do you have a read on which approach will be safer?

I don't have a perfect read here. The bug was quite niche. It only cropped up if you have a custom generic test that calls a macro which used to live in dbt_utils and has since moved to dbt. Some of the generic tests in dbt_utils probably fall into that category, though.

For now, it's probably slightly safer to just make this change for dbt-utils v1.0. We could consider backporting the fix from dbt-labs/dbt-core#5907 for a dbt-core v1.2.x patch release, if we don't see any negative repercussions. It would make this decision simpler.

@joellabes
Copy link
Contributor Author

For now, it's probably slightly safer to just make this change for dbt-utils v1.0

Agreed! 🔨🧑‍⚖️

@joellabes
Copy link
Contributor Author

Resolved by #701

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants