-
Notifications
You must be signed in to change notification settings - Fork 4.6k
🎉 MySQL destination: normalization #4163
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 34 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
55752a9
Add mysql dbt package
tuliren 049cfa2
Add mysql normalization support in java
tuliren 9165e80
Add mysql normalization support in python
tuliren 94c10be
Fix unit tests
tuliren 173ad67
Update readme
tuliren 3d9cbf7
Setup mysql container in integration test
tuliren 9e8e939
Add macros
tuliren 47945bf
Depend on dbt-mysql from git repo
tuliren 7f04076
Remove mysql limitation test
tuliren b9e3066
Test normalization
tuliren f13a95b
Revert protocol format change
tuliren dee3479
Fix mysel json macros
tuliren abe8eb7
Fix two more macros
tuliren a6acc91
Fix table name length
tuliren bbc3905
Fix array macro
tuliren 51fcb2a
Fix equality test macro
tuliren 5cbe550
Update replace-identifiers
tuliren 2396590
Merge branch 'master' into liren/mysql-destination-normalization
tuliren b7fe9cc
Add more identifiers to replace
tuliren 4a50b25
Fix unnest macro
tuliren 5c6642a
Fix equality macro
tuliren b71bd6d
Check in mysql test output
tuliren 5dc1cbb
Merge branch 'master' into liren/mysql-destination-normalization
tuliren b681fd0
Update column limit test for mysql
tuliren 02a8670
Escape parentheses
tuliren ffa5789
Remove unnecessary mysql test
tuliren 0cf0a17
Remove mysql output for easier code review
tuliren 411425f
Remove unnecessary mysql test
tuliren c43d06e
Remove parentheses
tuliren 091f137
Update dependencies
tuliren 78e030c
Skip mysql instead of manually write out types
tuliren e89122d
Bump version
tuliren ebf5cc4
Merge branch 'master' into liren/mysql-destination-normalization
tuliren f94b1c8
Check in unit test for mysql name transformer
tuliren 9310950
Fix type conversion
tuliren 1c68996
Use json_value to extract scalar json fields
tuliren 4e2a0dd
Move dbt-mysql to Dockerfile (#4459)
ChristopheDuong 5c49cc3
Format code
tuliren 46cab59
Check in mysql dbt output
tuliren aefc479
Remove unnecessary quote
tuliren 84e6e1c
Update mysql equality test to match 0.19.0
tuliren 0202369
Check in schema_test update
tuliren 967e1d8
Update readme
tuliren 73a1d25
Merge branch 'master' into liren/mysql-destination-normalization
tuliren f972e4b
Bump base normalization version
tuliren 289ba24
Update document
tuliren 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
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
3 changes: 3 additions & 0 deletions
3
...tegrations/bases/base-normalization/dbt-project-template/macros/cross_db_utils/except.sql
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,3 @@ | ||
{% macro mysql__except() %} | ||
{% do exceptions.warn("MySQL does not support EXCEPT operator") %} | ||
{% 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
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
69 changes: 69 additions & 0 deletions
69
...tegrations/bases/base-normalization/dbt-project-template/macros/schema_tests/equality.sql
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,69 @@ | ||
{# | ||
-- Adapted from https://github.com/fishtown-analytics/dbt-utils/blob/bbba960726667abc66b42624f0d36bbb62c37593/macros/schema_tests/equality.sql | ||
-- dbt-utils version: 0.6.4 | ||
-- This macro needs to be updated accordingly when dbt-utils is upgraded. | ||
-- This is needed because MySQL does not support the EXCEPT operator! | ||
#} | ||
|
||
{% macro mysql__test_equality(model, compare_model, compare_columns=None) %} | ||
|
||
{% set set_diff %} | ||
count(*) + coalesce(abs( | ||
sum(case when which_diff = 'a_minus_b' then 1 else 0 end) - | ||
sum(case when which_diff = 'b_minus_a' then 1 else 0 end) | ||
), 0) | ||
{% endset %} | ||
|
||
{{ config(fail_calc = set_diff) }} | ||
|
||
{%- if not execute -%} | ||
{{ return('') }} | ||
{% endif %} | ||
|
||
{%- do dbt_utils._is_relation(model, 'test_equality') -%} | ||
|
||
{%- if not compare_columns -%} | ||
{%- do dbt_utils._is_ephemeral(model, 'test_equality') -%} | ||
{%- set compare_columns = adapter.get_columns_in_relation(model) | map(attribute='quoted') -%} | ||
{%- endif -%} | ||
|
||
{% set compare_cols_csv = compare_columns | join(', ') %} | ||
|
||
with a as ( | ||
select * from {{ model }} | ||
), | ||
|
||
b as ( | ||
select * from {{ compare_model }} | ||
), | ||
|
||
a_minus_b as ( | ||
select {{ compare_cols_csv }} from a | ||
where ({{ compare_cols_csv }}) not in | ||
(select {{ compare_cols_csv }} from b) | ||
), | ||
|
||
b_minus_a as ( | ||
select {{ compare_cols_csv }} from b | ||
where ({{ compare_cols_csv }}) not in | ||
(select {{ compare_cols_csv }} from a) | ||
), | ||
|
||
unioned as ( | ||
select * from a_minus_b | ||
union all | ||
select * from b_minus_a | ||
), | ||
|
||
final as ( | ||
select (select count(*) from unioned) + | ||
(select abs( | ||
(select count(*) from a_minus_b) - | ||
(select count(*) from b_minus_a) | ||
)) | ||
as count | ||
) | ||
|
||
select count from final | ||
|
||
{% 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
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
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.