-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Normalization fix Snowflake Prefix Tables starting with number #9301
Merged
marcosmarxm
merged 24 commits into
master
from
marcos/normalization-snowflake-startwith-number
Jan 7, 2022
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
c6ae621
add normalization-clickhouse docker build step
jzcruiser b88225e
Merge branch 'patch-4' of github.com:jzcruiser/airbyte into marcos/te…
marcosmarxm cc499c2
bump normalization version
marcosmarxm a2517a3
small changes gradle
marcosmarxm 4a51799
Merge branch 'master' into marcos/test-pr-9029
marcosmarxm a57495c
fix settings gradle
marcosmarxm c56ef54
fix eof file
marcosmarxm f8ccfd6
correct clickhouse normalization
marcosmarxm f24ea4b
Merge branch 'master' into marcos/test-pr-9029
edgao a6e4c31
Refactor jinja template for scd (#9278)
ChristopheDuong 4f9f8ae
merge chris code and regenerate sql files
marcosmarxm 62e7dab
correct scd post-hook generation for snowflake
marcosmarxm b069b03
Merge branch 'master' into marcos/normalization-snowflake-startwith-n…
marcosmarxm 6a5f941
fix scd table for snowflake prefix table with number
marcosmarxm d8bb53f
scd fix for all destinations
marcosmarxm e6b0407
use quote
marcosmarxm 745fbf7
use normalize column for post-hook
marcosmarxm 96df256
change logic to apply quote
marcosmarxm 8495633
add logic to handle prefix for mssql and oracle
marcosmarxm 8f14292
run tests
marcosmarxm d06c537
merge master
marcosmarxm 5fee2a6
correct unit test
marcosmarxm 89cbcdb
Merge branch 'master' into marcos/normalization-snowflake-startwith-n…
marcosmarxm 29e047d
bump normalization version
marcosmarxm 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 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 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 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 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 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
2 changes: 1 addition & 1 deletion
2
...ms/models/generated/airbyte_incremental/scd/test_normalization/dedup_cdc_excluded_scd.sql
This file contains 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
2 changes: 1 addition & 1 deletion
2
...s/models/generated/airbyte_incremental/scd/test_normalization/dedup_exchange_rate_scd.sql
This file contains 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 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
2 changes: 1 addition & 1 deletion
2
...e_incremental/scd/test_normalization/nested_stream_with_co__lting_into_long_names_scd.sql
This file contains 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
2 changes: 1 addition & 1 deletion
2
...s/models/generated/airbyte_incremental/scd/test_normalization/dedup_exchange_rate_scd.sql
This file contains 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 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
2 changes: 1 addition & 1 deletion
2
...rbyte_incremental/scd/test_normalization/nested_stream_with_co_1g_into_long_names_scd.sql
This file contains 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
2 changes: 1 addition & 1 deletion
2
...s/models/generated/airbyte_incremental/scd/test_normalization/dedup_exchange_rate_scd.sql
This file contains 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 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
2 changes: 1 addition & 1 deletion
2
...s/models/generated/airbyte_incremental/scd/test_normalization/dedup_exchange_rate_scd.sql
This file contains 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 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 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 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 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
63 changes: 0 additions & 63 deletions
63
...ration_tests/normalization_test_output/postgres/test_simple_streams/first_dbt_project.yml
This file was deleted.
Oops, something went wrong.
85 changes: 85 additions & 0 deletions
85
...first_output/airbyte_incremental/scd/test_normalization/1_prefix_startwith_number_scd.sql
This file contains 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,85 @@ | ||
|
||
|
||
|
||
create table "postgres".test_normalization."1_prefix_startwith_number_scd" | ||
as ( | ||
|
||
-- depends_on: ref('1_prefix_startwith_number_stg') | ||
with | ||
|
||
input_data as ( | ||
select * | ||
from "postgres"._airbyte_test_normalization."1_prefix_startwith_number_stg" | ||
-- 1_prefix_startwith_number from "postgres".test_normalization._airbyte_raw_1_prefix_startwith_number | ||
), | ||
|
||
scd_data as ( | ||
-- SQL model to build a Type 2 Slowly Changing Dimension (SCD) table for each record identified by their primary key | ||
select | ||
md5(cast(coalesce(cast("id" as | ||
varchar | ||
), '') as | ||
varchar | ||
)) as _airbyte_unique_key, | ||
"id", | ||
"date", | ||
"text", | ||
"date" as _airbyte_start_at, | ||
lag("date") over ( | ||
partition by "id" | ||
order by | ||
"date" is null asc, | ||
"date" desc, | ||
_airbyte_emitted_at desc | ||
) as _airbyte_end_at, | ||
case when row_number() over ( | ||
partition by "id" | ||
order by | ||
"date" is null asc, | ||
"date" desc, | ||
_airbyte_emitted_at desc | ||
) = 1 then 1 else 0 end as _airbyte_active_row, | ||
_airbyte_ab_id, | ||
_airbyte_emitted_at, | ||
_airbyte_1_prefix_startwith_number_hashid | ||
from input_data | ||
), | ||
dedup_data as ( | ||
select | ||
-- we need to ensure de-duplicated rows for merge/update queries | ||
-- additionally, we generate a unique key for the scd table | ||
row_number() over ( | ||
partition by | ||
_airbyte_unique_key, | ||
_airbyte_start_at, | ||
_airbyte_emitted_at | ||
order by _airbyte_active_row desc, _airbyte_ab_id | ||
) as _airbyte_row_num, | ||
md5(cast(coalesce(cast(_airbyte_unique_key as | ||
varchar | ||
), '') || '-' || coalesce(cast(_airbyte_start_at as | ||
varchar | ||
), '') || '-' || coalesce(cast(_airbyte_emitted_at as | ||
varchar | ||
), '') as | ||
varchar | ||
)) as _airbyte_unique_key_scd, | ||
scd_data.* | ||
from scd_data | ||
) | ||
select | ||
_airbyte_unique_key, | ||
_airbyte_unique_key_scd, | ||
"id", | ||
"date", | ||
"text", | ||
_airbyte_start_at, | ||
_airbyte_end_at, | ||
_airbyte_active_row, | ||
_airbyte_ab_id, | ||
_airbyte_emitted_at, | ||
now() as _airbyte_normalized_at, | ||
_airbyte_1_prefix_startwith_number_hashid | ||
from dedup_data where _airbyte_row_num = 1 | ||
); | ||
|
24 changes: 24 additions & 0 deletions
24
...streams/first_output/airbyte_incremental/test_normalization/1_prefix_startwith_number.sql
This file contains 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,24 @@ | ||
|
||
|
||
|
||
create table "postgres".test_normalization."1_prefix_startwith_number" | ||
as ( | ||
|
||
-- Final base SQL model | ||
-- depends_on: "postgres".test_normalization."1_prefix_startwith_number_scd" | ||
select | ||
_airbyte_unique_key, | ||
"id", | ||
"date", | ||
"text", | ||
_airbyte_ab_id, | ||
_airbyte_emitted_at, | ||
now() as _airbyte_normalized_at, | ||
_airbyte_1_prefix_startwith_number_hashid | ||
from "postgres".test_normalization."1_prefix_startwith_number_scd" | ||
-- 1_prefix_startwith_number from "postgres".test_normalization._airbyte_raw_1_prefix_startwith_number | ||
where 1 = 1 | ||
and _airbyte_active_row = 1 | ||
|
||
); | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you know why these are changing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I didn't change it directly!