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

Change union macro to not always include the _dbt_source_relation column #331

Closed
joellabes opened this issue Feb 1, 2021 · 6 comments
Closed
Assignees
Labels
enhancement New feature or request good first issue

Comments

@joellabes
Copy link
Contributor

Describe the feature

When developing, the _dbt_source_relation column from the union macro is useful to check that things are behaving properly, but once it's all working properly I don't like exposing implementation details to output models. I'd like to be able to opt out of that column being added at the front of my model.

Describe alternatives you've considered

  • Adding another intermediary model which uses the star macro, passing the column into the except arg
  • Maintaining an internal copy of this macro

Who will this benefit?

Me! In this case, it's a legacy hard-delete-finding snapshot using my snapshot-sandwich approach, and we've added another column but they're out of order and don't union nicely anymore.

Are you interested in contributing this feature?

Yes - I was planning to just wrap the cast({{ dbt_utils.string_literal(relation) }} as {{ dbt_utils.type_string() }}) as {{ source_column_name }} line in an {% if source_column_name %} block, so you can pass None in if you don't want the column. Open to alternative approaches though (a new bool is more explicit, but getting towards a pretty unwieldy signature)

@joellabes joellabes added enhancement New feature or request triage labels Feb 1, 2021
@chloe-lubin
Copy link

Hi @joellabes , that would be a great feature. I look forward to seeing its release in the future. I'd like to suggest another feature to the union_relations macro: is it possible to preserve the order of the columns if either of the models does not have a column instead of sending it to the end of the table? Thanks!

Ex:

table 1

id name email

table 2

id email

unioned table

id name email

instead of

id email name

@joellabes
Copy link
Contributor Author

@chloe-lubin thanks for suggesting this! Could I ask you to open a new issue so that it can be prioritised/discovered separately to this one?

@chloe-lubin
Copy link

No problem! I opened a new issue here.

@christineberger
Copy link
Contributor

christineberger commented May 24, 2022

@joellabes is there any plans to add this feature?

@joellabes
Copy link
Contributor Author

@christineberger I have to say that I absolutely agree with my past self here! The joys of triaging issues you made while still on the outside 😅

I think passing in None as the column name and checking for it is a good approach - if you want to implement it yourself, you're extremely welcome to!

If not, I'll try and get it done before utils 1.0.0, which we're starting to think pretty seriously about

@joellabes
Copy link
Contributor Author

Resolved by #624

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue
Projects
None yet
Development

No branches or pull requests

3 participants