-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Fix normalization issue with quoted & case sensitive columns (#9317)
- Loading branch information
1 parent
e0bac4a
commit c5d4a97
Showing
43 changed files
with
1,030 additions
and
267 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
83 changes: 83 additions & 0 deletions
83
...ams/first_output/airbyte_views/test_normalization/multiple_column_names_conflicts_stg.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,83 @@ | ||
|
||
|
||
create or replace view `dataline-integration-testing`._airbyte_test_normalization.`multiple_column_names_conflicts_stg` | ||
OPTIONS() | ||
as | ||
with __dbt__cte__multiple_column_names_conflicts_ab1 as ( | ||
|
||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema | ||
-- depends_on: `dataline-integration-testing`.test_normalization._airbyte_raw_multiple_column_names_conflicts | ||
select | ||
json_extract_scalar(_airbyte_data, "$['id']") as id, | ||
json_extract_scalar(_airbyte_data, "$['User Id']") as User_Id, | ||
json_extract_scalar(_airbyte_data, "$['user_id']") as user_id_1, | ||
json_extract_scalar(_airbyte_data, "$['User id']") as User_id_2, | ||
json_extract_scalar(_airbyte_data, "$['user id']") as user_id_3, | ||
json_extract_scalar(_airbyte_data, "$['User@Id']") as User_Id_4, | ||
json_extract_scalar(_airbyte_data, "$['UserId']") as UserId, | ||
_airbyte_ab_id, | ||
_airbyte_emitted_at, | ||
CURRENT_TIMESTAMP() as _airbyte_normalized_at | ||
from `dataline-integration-testing`.test_normalization._airbyte_raw_multiple_column_names_conflicts as table_alias | ||
-- multiple_column_names_conflicts | ||
where 1 = 1 | ||
|
||
), __dbt__cte__multiple_column_names_conflicts_ab2 as ( | ||
|
||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type | ||
-- depends_on: __dbt__cte__multiple_column_names_conflicts_ab1 | ||
select | ||
cast(id as | ||
int64 | ||
) as id, | ||
cast(User_Id as | ||
string | ||
) as User_Id, | ||
cast(user_id_1 as | ||
float64 | ||
) as user_id_1, | ||
cast(User_id_2 as | ||
float64 | ||
) as User_id_2, | ||
cast(user_id_3 as | ||
float64 | ||
) as user_id_3, | ||
cast(User_Id_4 as | ||
string | ||
) as User_Id_4, | ||
cast(UserId as | ||
float64 | ||
) as UserId, | ||
_airbyte_ab_id, | ||
_airbyte_emitted_at, | ||
CURRENT_TIMESTAMP() as _airbyte_normalized_at | ||
from __dbt__cte__multiple_column_names_conflicts_ab1 | ||
-- multiple_column_names_conflicts | ||
where 1 = 1 | ||
|
||
)-- SQL model to build a hash column based on the values of this record | ||
-- depends_on: __dbt__cte__multiple_column_names_conflicts_ab2 | ||
select | ||
to_hex(md5(cast(concat(coalesce(cast(id as | ||
string | ||
), ''), '-', coalesce(cast(User_Id as | ||
string | ||
), ''), '-', coalesce(cast(user_id_1 as | ||
string | ||
), ''), '-', coalesce(cast(User_id_2 as | ||
string | ||
), ''), '-', coalesce(cast(user_id_3 as | ||
string | ||
), ''), '-', coalesce(cast(User_Id_4 as | ||
string | ||
), ''), '-', coalesce(cast(UserId as | ||
string | ||
), '')) as | ||
string | ||
))) as _airbyte_multiple_column_names_conflicts_hashid, | ||
tmp.* | ||
from __dbt__cte__multiple_column_names_conflicts_ab2 tmp | ||
-- multiple_column_names_conflicts | ||
where 1 = 1 | ||
; | ||
|
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
34 changes: 0 additions & 34 deletions
34
...simple_streams/first_output/airbyte_incremental/test_normalization/dedup_cdc_excluded.sql
This file was deleted.
Oops, something went wrong.
86 changes: 86 additions & 0 deletions
86
...ams/first_output/airbyte_views/test_normalization/multiple_column_names_conflicts_stg.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,86 @@ | ||
|
||
|
||
create view _airbyte_test_normalization.multiple_column_names_conflicts_stg__dbt_tmp | ||
|
||
as ( | ||
|
||
with __dbt__cte__multiple_column_names_conflicts_ab1 as ( | ||
|
||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema | ||
-- depends_on: test_normalization._airbyte_raw_multiple_column_names_conflicts | ||
select | ||
JSONExtractRaw(_airbyte_data, 'id') as id, | ||
JSONExtractRaw(_airbyte_data, 'User Id') as "User Id", | ||
JSONExtractRaw(_airbyte_data, 'user_id') as user_id, | ||
JSONExtractRaw(_airbyte_data, 'User id') as "User id", | ||
JSONExtractRaw(_airbyte_data, 'user id') as "user id", | ||
JSONExtractRaw(_airbyte_data, 'User@Id') as "User@Id", | ||
JSONExtractRaw(_airbyte_data, 'UserId') as UserId, | ||
_airbyte_ab_id, | ||
_airbyte_emitted_at, | ||
now() as _airbyte_normalized_at | ||
from test_normalization._airbyte_raw_multiple_column_names_conflicts as table_alias | ||
-- multiple_column_names_conflicts | ||
where 1 = 1 | ||
|
||
), __dbt__cte__multiple_column_names_conflicts_ab2 as ( | ||
|
||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type | ||
-- depends_on: __dbt__cte__multiple_column_names_conflicts_ab1 | ||
select | ||
accurateCastOrNull(id, ' | ||
BIGINT | ||
') as id, | ||
nullif(accurateCastOrNull(trim(BOTH '"' from "User Id"), 'String'), 'null') as "User Id", | ||
accurateCastOrNull(user_id, ' | ||
Float64 | ||
') as user_id, | ||
accurateCastOrNull("User id", ' | ||
Float64 | ||
') as "User id", | ||
accurateCastOrNull("user id", ' | ||
Float64 | ||
') as "user id", | ||
nullif(accurateCastOrNull(trim(BOTH '"' from "User@Id"), 'String'), 'null') as "User@Id", | ||
accurateCastOrNull(UserId, ' | ||
Float64 | ||
') as UserId, | ||
_airbyte_ab_id, | ||
_airbyte_emitted_at, | ||
now() as _airbyte_normalized_at | ||
from __dbt__cte__multiple_column_names_conflicts_ab1 | ||
-- multiple_column_names_conflicts | ||
where 1 = 1 | ||
|
||
)-- SQL model to build a hash column based on the values of this record | ||
-- depends_on: __dbt__cte__multiple_column_names_conflicts_ab2 | ||
select | ||
assumeNotNull(hex(MD5( | ||
|
||
toString(id) || '~' || | ||
|
||
|
||
toString("User Id") || '~' || | ||
|
||
|
||
toString(user_id) || '~' || | ||
|
||
|
||
toString("User id") || '~' || | ||
|
||
|
||
toString("user id") || '~' || | ||
|
||
|
||
toString("User@Id") || '~' || | ||
|
||
|
||
toString(UserId) | ||
|
||
))) as _airbyte_multiple_co__ames_conflicts_hashid, | ||
tmp.* | ||
from __dbt__cte__multiple_column_names_conflicts_ab2 tmp | ||
-- multiple_column_names_conflicts | ||
where 1 = 1 | ||
|
||
) |
21 changes: 0 additions & 21 deletions
21
...imple_streams/models/generated/airbyte_ctes/test_normalization/dedup_cdc_excluded_ab1.sql
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
...imple_streams/models/generated/airbyte_ctes/test_normalization/dedup_cdc_excluded_ab2.sql
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
...est_simple_streams/models/generated/airbyte_ctes/test_normalization/exchange_rate_ab1.sql
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
...est_simple_streams/models/generated/airbyte_ctes/test_normalization/exchange_rate_ab2.sql
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
...est_simple_streams/models/generated/airbyte_ctes/test_normalization/exchange_rate_ab3.sql
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
...st_simple_streams/models/generated/airbyte_ctes/test_normalization/pos_dedup_cdcx_ab1.sql
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
...st_simple_streams/models/generated/airbyte_ctes/test_normalization/pos_dedup_cdcx_ab2.sql
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.