question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change union macro to not always include the _dbt_source_relation column

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
joellabescommented, Apr 8, 2022

@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?

0reactions
joellabescommented, Jul 26, 2022

Resolved by #624

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change union macro to not always include the ... - GitHub
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...
Read more >
Towards an Error-free UNION ALL | dbt Developer Blog
The union_relations macro in the dbt_utils package completely frees us from propagating null or 0 values for each column that doesn't exist in ......
Read more >
Run a macro when certain cells change in Excel - Office
In Microsoft Excel, you can create a macro that is called only when a value is entered into a cell in a particular...
Read more >
Row Height - Column Width - VBA Code Examples
AutoMacro : Ultimate VBA Add-in. AutoMacro. “AutoMacro is the best purchase I have made in a long time. This has helped me streamline...
Read more >
For Loop not fully cycling in excel VBA - Stack Overflow
If I then run the macro again it will successfully delete all the columns I ask it to. If I switch the macro...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found