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

Feature: Add option to remove the source_column_name on the union_relations macro #624

Merged
merged 6 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
## Contributors:
--->

# Unreleased

## New features
- New feature to omit the `source_column_name` column on the `union_relations` macro ([#331](https://github.com/dbt-labs/dbt-utils/issues/331), [#624](https://github.com/dbt-labs/dbt-utils/pull/624))

## Contributors:
- [@christineberger](https://github.com/christineberger) (#624)

# dbt-utils v0.8.6

## New features
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,8 @@ final query. Note the `include` and `exclude` arguments are mutually exclusive.
* `column_override` (optional): A dictionary of explicit column type overrides,
e.g. `{"some_field": "varchar(100)"}`.``
* `source_column_name` (optional, `default="_dbt_source_relation"`): The name of
the column that records the source of this row.
the column that records the source of this row. `source_column_name: none` can
be used to omit this column.
* `where` (optional): Filter conditions to include in the `where` clause.

#### generate_series ([source](macros/sql/generate_series.sql))
Expand Down
3 changes: 3 additions & 0 deletions macros/sql/union.sql
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@
(
select

{%- if source_column_name != none %}
cast({{ dbt_utils.string_literal(relation) }} as {{ dbt_utils.type_string() }}) as {{ source_column_name }},
{%- endif %}

{% for col_name in ordered_column_names -%}

{%- set col = column_superset[col_name] %}
Expand Down