-
Notifications
You must be signed in to change notification settings - Fork 24
feature/union-data #71
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
0750e91
feature/union-data
fivetran-catfritz 5e7b061
add new files
fivetran-catfritz 8731319
fixes
fivetran-catfritz 7996d58
adjust staging
fivetran-catfritz edb9fb5
update tests
fivetran-catfritz 6e48fb4
fixes
fivetran-catfritz 0847422
changelog
fivetran-catfritz b80a7d6
update docs
fivetran-catfritz 5ee26fb
Generate dbt docs via GitHub Actions
github-actions[bot] 66af67a
update tests
fivetran-catfritz d374b1c
update tests
fivetran-catfritz 49031b5
changelog
fivetran-catfritz b866815
one more test update
fivetran-catfritz 5393797
update union_connections
fivetran-catfritz fd38316
update union_connections
fivetran-catfritz 1315d4a
update union_connections
fivetran-catfritz 5efbf7a
update github_union_connections
fivetran-catfritz 210b65c
put back the thing
fivetran-catfritz a66527a
Apply suggestions from code review
fivetran-catfritz 453f703
update source enablement
fivetran-catfritz b3f000c
changelog
fivetran-catfritz 7712c9c
changelog
fivetran-catfritz 5aab18a
Apply suggestions from code review
fivetran-catfritz 05653d2
update src configs
fivetran-catfritz 6139bcd
Update CHANGELOG.md
fivetran-catfritz a5f4825
formatting
fivetran-catfritz b2ee9bf
Merge branch 'feature/union-data' of https://github.com/fivetran/dbt_…
fivetran-catfritz 7ec576b
Generate dbt docs via GitHub Actions
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,3 +71,5 @@ env/ | |
| env.bak/ | ||
| venv/ | ||
| venv.bak/ | ||
|
|
||
| CLAUDE.md | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| {% macro apply_source_relation() -%} | ||
|
|
||
| {{ adapter.dispatch('apply_source_relation', 'github') () }} | ||
|
|
||
| {%- endmacro %} | ||
|
|
||
| {% macro default__apply_source_relation() -%} | ||
|
|
||
| {% if var('github_sources', []) != [] %} | ||
| , _dbt_source_relation as source_relation | ||
| {% else %} | ||
| , '{{ var("github_database", target.database) }}' || '.'|| '{{ var("github_schema", "github") }}' as source_relation | ||
| {% endif %} | ||
|
|
||
| {%- endmacro %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| {% macro github_union_connections(connection_dictionary, single_source_name, single_table_name, default_identifier=single_table_name) %} | ||
fivetran-jamie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| {{ adapter.dispatch('github_union_connections', 'github') (connection_dictionary, single_source_name, single_table_name, default_identifier) }} | ||
|
|
||
| {%- endmacro %} | ||
|
|
||
| {% macro default__github_union_connections(connection_dictionary, single_source_name, single_table_name, default_identifier=single_table_name) %} | ||
fivetran-jamie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| {%- set exception_warning = "\n\nPlease be aware: The " ~ single_source_name|upper ~ "." ~ single_table_name|upper ~ " table was not found in your schema(s). The Fivetran Data Model will create a completely empty staging model as to not break downstream transformations. To turn off these warnings, set the `fivetran__remove_empty_table_warnings` variable to TRUE (see https://github.com/fivetran/dbt_fivetran_utils/tree/releases/v0.4.latest#union_data-source for details).\n"%} | ||
| {%- set using_empty_table_warnings = (execute and not var('fivetran__remove_empty_table_warnings', false)) %} | ||
| {%- set connections = var(connection_dictionary, []) %} | ||
| {%- set using_unioning = connections | length > 0 %} | ||
|
|
||
| {%- if using_unioning %} | ||
| {# For unioning #} | ||
| {%- set relations = [] -%} | ||
| {%- for connection in connections -%} | ||
|
|
||
| {% if var('has_defined_sources', false) %} | ||
| {%- set database = source(connection.name, single_table_name).database %} | ||
| {%- set schema = source(connection.name, single_table_name).schema %} | ||
| {%- set identifier = source(connection.name, single_table_name).identifier %} | ||
| {%- else %} | ||
| {%- set database = connection.database if connection.database else target.database %} | ||
| {%- set schema = connection.schema if connection.schema else single_source_name %} | ||
| {%- set identifier = default_identifier %} | ||
| {%- endif %} | ||
|
|
||
| {%- set relation=adapter.get_relation( | ||
| database=database, | ||
| schema=schema, | ||
| identifier=identifier | ||
| ) | ||
| -%} | ||
|
|
||
| {%- if relation is not none -%} | ||
| {%- do relations.append(relation) -%} | ||
| {%- endif -%} | ||
|
|
||
| -- ** Values passed to adapter.get_relation: | ||
| {{ '-- full-identifier_var: ' ~ identifier_var }} | ||
| {{ '-- database: ' ~ database }} | ||
| {{ '-- schema: ' ~ schema }} | ||
| {{ '-- identifier: ' ~ identifier ~ '\n' }} | ||
|
|
||
| {%- endfor -%} | ||
|
|
||
| {%- if relations != [] -%} | ||
| {{ github.github_union_relations(relations) }} | ||
|
|
||
| {%- else -%} | ||
| {{ exceptions.warn(exception_warning) if using_empty_table_warnings }} | ||
|
|
||
| select | ||
| cast(null as {{ dbt.type_string() }}) as _dbt_source_relation | ||
| limit {{ '0' if target.type != 'redshift' else '1' }} | ||
| {%- endif -%} | ||
|
|
||
| {% else %} | ||
| {# Not unioning #} | ||
|
|
||
| {% set identifier_var = single_source_name + "_" + single_table_name + "_identifier"%} | ||
| {%- set database = source(single_source_name, single_table_name).database %} | ||
| {%- set schema = source(single_source_name, single_table_name).schema %} | ||
| {%- set identifier = source(single_source_name, single_table_name).identifier %} | ||
|
|
||
| {%- set relation=adapter.get_relation( | ||
| database=database, | ||
| schema=schema, | ||
| identifier=identifier | ||
| ) | ||
| -%} | ||
|
|
||
| -- ** Values passed to adapter.get_relation: | ||
| {{ '-- full-identifier_var: ' ~ identifier_var }} | ||
| {{ '-- database: ' ~ database }} | ||
| {{ '-- schema: ' ~ schema }} | ||
| {{ '-- identifier: ' ~ identifier ~ '\n' }} | ||
|
|
||
| {% if relation is not none -%} | ||
| select | ||
| {{ dbt_utils.star(from=source(single_source_name, single_table_name)) }} | ||
| from {{ source(single_source_name, single_table_name) }} as source_table | ||
|
|
||
| {% else %} | ||
| {{ exceptions.warn(exception_warning) if using_empty_table_warnings }} | ||
|
|
||
| select | ||
| cast(null as {{ dbt.type_string() }}) as _dbt_source_relation | ||
| limit {{ '0' if target.type != 'redshift' else '1' }} | ||
| {%- endif -%} | ||
| {% endif -%} | ||
|
|
||
| {%- endmacro %} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.