Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalization: solve conflict when stream and field have same name (#…
…4557) * solve conflict when stream and field have same name * add logic to handle conflict * change files * change json_extract functions * json_operations * add normalization files * test integration mysql * remove table_alias * mysql run * json ops * solve conflict with master * solve mysql circle dependency dbt * add tests for scalar and arrays * add sql files * bump normalization version * format
- Loading branch information
1 parent
87b8696
commit e4fe62f
Showing
424 changed files
with
3,859 additions
and
434 deletions.
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
13 changes: 13 additions & 0 deletions
13
...t_primary_key_streams/final/airbyte_ctes/test_normalization/conflict_stream_array_ab1.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,13 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_array_ab1` | ||
OPTIONS() | ||
as | ||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema | ||
select | ||
json_extract_scalar(_airbyte_data, "$['id']") as id, | ||
json_extract(table_alias._airbyte_data, "$['conflict_stream_array']") as conflict_stream_array, | ||
_airbyte_emitted_at | ||
from `dataline-integration-testing`.test_normalization._airbyte_raw_conflict_stream_array as table_alias | ||
-- conflict_stream_array; | ||
|
17 changes: 17 additions & 0 deletions
17
...t_primary_key_streams/final/airbyte_ctes/test_normalization/conflict_stream_array_ab2.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,17 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_array_ab2` | ||
OPTIONS() | ||
as | ||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type | ||
select | ||
cast(id as | ||
string | ||
) as id, | ||
cast(conflict_stream_array as | ||
string | ||
) as conflict_stream_array, | ||
_airbyte_emitted_at | ||
from `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_array_ab1` | ||
-- conflict_stream_array; | ||
|
18 changes: 18 additions & 0 deletions
18
...t_primary_key_streams/final/airbyte_ctes/test_normalization/conflict_stream_array_ab3.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,18 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_array_ab3` | ||
OPTIONS() | ||
as | ||
-- SQL model to build a hash column based on the values of this record | ||
select | ||
*, | ||
to_hex(md5(cast(concat(coalesce(cast(id as | ||
string | ||
), ''), '-', coalesce(cast(conflict_stream_array as | ||
string | ||
), '')) as | ||
string | ||
))) as _airbyte_conflict_stream_array_hashid | ||
from `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_array_ab2` | ||
-- conflict_stream_array; | ||
|
14 changes: 14 additions & 0 deletions
14
...final/airbyte_ctes/test_normalization/conflict_stream_array_conflict_stream_array_ab1.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,14 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_array_conflict_stream_array_ab1` | ||
OPTIONS() | ||
as | ||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema | ||
select | ||
_airbyte_conflict_stream_array_hashid, | ||
json_extract_array(conflict_stream_array, "$['conflict_stream_name']") as conflict_stream_name, | ||
_airbyte_emitted_at | ||
from `dataline-integration-testing`.test_normalization.`conflict_stream_array` as table_alias | ||
where conflict_stream_array is not null | ||
-- conflict_stream_array at conflict_stream_array/conflict_stream_array; | ||
|
13 changes: 13 additions & 0 deletions
13
...final/airbyte_ctes/test_normalization/conflict_stream_array_conflict_stream_array_ab2.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,13 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_array_conflict_stream_array_ab2` | ||
OPTIONS() | ||
as | ||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type | ||
select | ||
_airbyte_conflict_stream_array_hashid, | ||
conflict_stream_name, | ||
_airbyte_emitted_at | ||
from `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_array_conflict_stream_array_ab1` | ||
-- conflict_stream_array at conflict_stream_array/conflict_stream_array; | ||
|
18 changes: 18 additions & 0 deletions
18
...final/airbyte_ctes/test_normalization/conflict_stream_array_conflict_stream_array_ab3.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,18 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_array_conflict_stream_array_ab3` | ||
OPTIONS() | ||
as | ||
-- SQL model to build a hash column based on the values of this record | ||
select | ||
*, | ||
to_hex(md5(cast(concat(coalesce(cast(_airbyte_conflict_stream_array_hashid as | ||
string | ||
), ''), '-', coalesce(cast(array_to_string(conflict_stream_name, "|", "") as | ||
string | ||
), '')) as | ||
string | ||
))) as _airbyte_conflict_stream_array_2_hashid | ||
from `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_array_conflict_stream_array_ab2` | ||
-- conflict_stream_array at conflict_stream_array/conflict_stream_array; | ||
|
16 changes: 16 additions & 0 deletions
16
...st_normalization/conflict_stream_array_conflict_stream_array_conflict_stream_name_ab1.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,16 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_array_conflict_stream_array_conflict_stream_name_ab1` | ||
OPTIONS() | ||
as | ||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema | ||
|
||
select | ||
_airbyte_conflict_stream_array_2_hashid, | ||
json_extract_scalar(conflict_stream_name, "$['id']") as id, | ||
_airbyte_emitted_at | ||
from `dataline-integration-testing`.test_normalization.`conflict_stream_array_conflict_stream_array` as table_alias | ||
cross join unnest(conflict_stream_name) as conflict_stream_name | ||
where conflict_stream_name is not null | ||
-- conflict_stream_name at conflict_stream_array/conflict_stream_array/conflict_stream_name; | ||
|
15 changes: 15 additions & 0 deletions
15
...st_normalization/conflict_stream_array_conflict_stream_array_conflict_stream_name_ab2.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,15 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_array_conflict_stream_array_conflict_stream_name_ab2` | ||
OPTIONS() | ||
as | ||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type | ||
select | ||
_airbyte_conflict_stream_array_2_hashid, | ||
cast(id as | ||
int64 | ||
) as id, | ||
_airbyte_emitted_at | ||
from `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_array_conflict_stream_array_conflict_stream_name_ab1` | ||
-- conflict_stream_name at conflict_stream_array/conflict_stream_array/conflict_stream_name; | ||
|
18 changes: 18 additions & 0 deletions
18
...st_normalization/conflict_stream_array_conflict_stream_array_conflict_stream_name_ab3.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,18 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_array_conflict_stream_array_conflict_stream_name_ab3` | ||
OPTIONS() | ||
as | ||
-- SQL model to build a hash column based on the values of this record | ||
select | ||
*, | ||
to_hex(md5(cast(concat(coalesce(cast(_airbyte_conflict_stream_array_2_hashid as | ||
string | ||
), ''), '-', coalesce(cast(id as | ||
string | ||
), '')) as | ||
string | ||
))) as _airbyte_conflict_stream_name_hashid | ||
from `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_array_conflict_stream_array_conflict_stream_name_ab2` | ||
-- conflict_stream_name at conflict_stream_array/conflict_stream_array/conflict_stream_name; | ||
|
13 changes: 13 additions & 0 deletions
13
...st_primary_key_streams/final/airbyte_ctes/test_normalization/conflict_stream_name_ab1.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,13 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_name_ab1` | ||
OPTIONS() | ||
as | ||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema | ||
select | ||
json_extract_scalar(_airbyte_data, "$['id']") as id, | ||
json_extract(table_alias._airbyte_data, "$['conflict_stream_name']") as conflict_stream_name, | ||
_airbyte_emitted_at | ||
from `dataline-integration-testing`.test_normalization._airbyte_raw_conflict_stream_name as table_alias | ||
-- conflict_stream_name; | ||
|
17 changes: 17 additions & 0 deletions
17
...st_primary_key_streams/final/airbyte_ctes/test_normalization/conflict_stream_name_ab2.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,17 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_name_ab2` | ||
OPTIONS() | ||
as | ||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type | ||
select | ||
cast(id as | ||
string | ||
) as id, | ||
cast(conflict_stream_name as | ||
string | ||
) as conflict_stream_name, | ||
_airbyte_emitted_at | ||
from `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_name_ab1` | ||
-- conflict_stream_name; | ||
|
18 changes: 18 additions & 0 deletions
18
...st_primary_key_streams/final/airbyte_ctes/test_normalization/conflict_stream_name_ab3.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,18 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_name_ab3` | ||
OPTIONS() | ||
as | ||
-- SQL model to build a hash column based on the values of this record | ||
select | ||
*, | ||
to_hex(md5(cast(concat(coalesce(cast(id as | ||
string | ||
), ''), '-', coalesce(cast(conflict_stream_name as | ||
string | ||
), '')) as | ||
string | ||
))) as _airbyte_conflict_stream_name_hashid | ||
from `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_name_ab2` | ||
-- conflict_stream_name; | ||
|
14 changes: 14 additions & 0 deletions
14
...s/final/airbyte_ctes/test_normalization/conflict_stream_name_conflict_stream_name_ab1.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,14 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_name_conflict_stream_name_ab1` | ||
OPTIONS() | ||
as | ||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema | ||
select | ||
_airbyte_conflict_stream_name_hashid, | ||
json_extract(table_alias.conflict_stream_name, "$['conflict_stream_name']") as conflict_stream_name, | ||
_airbyte_emitted_at | ||
from `dataline-integration-testing`.test_normalization.`conflict_stream_name` as table_alias | ||
where conflict_stream_name is not null | ||
-- conflict_stream_name at conflict_stream_name/conflict_stream_name; | ||
|
15 changes: 15 additions & 0 deletions
15
...s/final/airbyte_ctes/test_normalization/conflict_stream_name_conflict_stream_name_ab2.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,15 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_name_conflict_stream_name_ab2` | ||
OPTIONS() | ||
as | ||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type | ||
select | ||
_airbyte_conflict_stream_name_hashid, | ||
cast(conflict_stream_name as | ||
string | ||
) as conflict_stream_name, | ||
_airbyte_emitted_at | ||
from `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_name_conflict_stream_name_ab1` | ||
-- conflict_stream_name at conflict_stream_name/conflict_stream_name; | ||
|
18 changes: 18 additions & 0 deletions
18
...s/final/airbyte_ctes/test_normalization/conflict_stream_name_conflict_stream_name_ab3.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,18 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_name_conflict_stream_name_ab3` | ||
OPTIONS() | ||
as | ||
-- SQL model to build a hash column based on the values of this record | ||
select | ||
*, | ||
to_hex(md5(cast(concat(coalesce(cast(_airbyte_conflict_stream_name_hashid as | ||
string | ||
), ''), '-', coalesce(cast(conflict_stream_name as | ||
string | ||
), '')) as | ||
string | ||
))) as _airbyte_conflict_stream_name_2_hashid | ||
from `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_name_conflict_stream_name_ab2` | ||
-- conflict_stream_name at conflict_stream_name/conflict_stream_name; | ||
|
14 changes: 14 additions & 0 deletions
14
...test_normalization/conflict_stream_name_conflict_stream_name_conflict_stream_name_ab1.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,14 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_name_conflict_stream_name_conflict_stream_name_ab1` | ||
OPTIONS() | ||
as | ||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema | ||
select | ||
_airbyte_conflict_stream_name_2_hashid, | ||
json_extract_scalar(conflict_stream_name, "$['groups']") as `groups`, | ||
_airbyte_emitted_at | ||
from `dataline-integration-testing`.test_normalization.`conflict_stream_name_conflict_stream_name` as table_alias | ||
where conflict_stream_name is not null | ||
-- conflict_stream_name at conflict_stream_name/conflict_stream_name/conflict_stream_name; | ||
|
15 changes: 15 additions & 0 deletions
15
...test_normalization/conflict_stream_name_conflict_stream_name_conflict_stream_name_ab2.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,15 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_name_conflict_stream_name_conflict_stream_name_ab2` | ||
OPTIONS() | ||
as | ||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type | ||
select | ||
_airbyte_conflict_stream_name_2_hashid, | ||
cast(`groups` as | ||
string | ||
) as `groups`, | ||
_airbyte_emitted_at | ||
from `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_name_conflict_stream_name_conflict_stream_name_ab1` | ||
-- conflict_stream_name at conflict_stream_name/conflict_stream_name/conflict_stream_name; | ||
|
18 changes: 18 additions & 0 deletions
18
...test_normalization/conflict_stream_name_conflict_stream_name_conflict_stream_name_ab3.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,18 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_name_conflict_stream_name_conflict_stream_name_ab3` | ||
OPTIONS() | ||
as | ||
-- SQL model to build a hash column based on the values of this record | ||
select | ||
*, | ||
to_hex(md5(cast(concat(coalesce(cast(_airbyte_conflict_stream_name_2_hashid as | ||
string | ||
), ''), '-', coalesce(cast(`groups` as | ||
string | ||
), '')) as | ||
string | ||
))) as _airbyte_conflict_stream_name_3_hashid | ||
from `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_name_conflict_stream_name_conflict_stream_name_ab2` | ||
-- conflict_stream_name at conflict_stream_name/conflict_stream_name/conflict_stream_name; | ||
|
13 changes: 13 additions & 0 deletions
13
..._primary_key_streams/final/airbyte_ctes/test_normalization/conflict_stream_scalar_ab1.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,13 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`conflict_stream_scalar_ab1` | ||
OPTIONS() | ||
as | ||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema | ||
select | ||
json_extract_scalar(_airbyte_data, "$['id']") as id, | ||
json_extract_scalar(_airbyte_data, "$['conflict_stream_scalar']") as conflict_stream_scalar, | ||
_airbyte_emitted_at | ||
from `dataline-integration-testing`.test_normalization._airbyte_raw_conflict_stream_scalar as table_alias | ||
-- conflict_stream_scalar; | ||
|
Oops, something went wrong.