-
Notifications
You must be signed in to change notification settings - Fork 25
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
Bug/redshift json parse #114
Merged
Merged
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
d7c0319
bug/redshift-json-parse
fivetran-catfritz 3fd8796
bug/redshift-json-parse
fivetran-catfritz 548f017
update
fivetran-catfritz 4ec7578
update
fivetran-catfritz d489457
updates
fivetran-catfritz 85689b7
update macro
fivetran-catfritz 1709d45
update macro
fivetran-catfritz 480c346
update macro
fivetran-catfritz 77978d3
update seed
fivetran-catfritz 5a80eac
update
fivetran-catfritz 9ffff41
updates
fivetran-catfritz 1d8b875
updates
fivetran-catfritz c76acf1
updates
fivetran-catfritz b05ec50
updates
fivetran-catfritz 32b9428
updates
fivetran-catfritz 193b665
updates
fivetran-catfritz 1c6a764
updates
fivetran-catfritz dfc7ad5
update incremental
fivetran-catfritz 2ec773f
add lookback
fivetran-catfritz be958da
add lookback
fivetran-catfritz 6d2d1e1
add lookback
fivetran-catfritz 1aaeb0f
update current time
fivetran-catfritz bcbe017
updates
fivetran-catfritz 075b720
updates
fivetran-catfritz 5a0e356
updates
fivetran-catfritz 5384a99
json updates
fivetran-catfritz c90d51d
json updates
fivetran-catfritz 24cc4fc
incremental updates
fivetran-catfritz 205ce6a
incremental updates
fivetran-catfritz b5ad8e9
updates && regen docs
fivetran-catfritz 5aa991a
updates yml
fivetran-catfritz a6b7406
update changelog
fivetran-catfritz ac435aa
add bq logic
fivetran-catfritz d4d85fd
add bq logic
fivetran-catfritz 01f0612
add bq logic
fivetran-catfritz dae512d
Apply suggestions from code review
fivetran-catfritz dd75c37
Apply suggestions from code review
fivetran-catfritz 2618f01
update comment
fivetran-catfritz 41e0792
update
fivetran-catfritz 6a69d61
update changelog
fivetran-catfritz f50c281
update changelog
fivetran-catfritz 3dfecb7
update changelog
fivetran-catfritz 675f56a
update changelog
fivetran-catfritz ea57b23
Update CHANGELOG.md
fivetran-catfritz d26da8a
regen docs
fivetran-catfritz 0fca474
update changelog
fivetran-catfritz 56b1214
update changelog
fivetran-catfritz 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
connector_id,_fivetran_synced,connecting_user_id,connector_name,connector_type,destination_id,paused,signed_up,_fivetran_deleted | ||
this_connector,2021-03-12 21:03:45.994,,this_connector,s3,ups_trampoline,true,2020-08-31 19:00:22.913630,false | ||
this_connector,2021-03-12 21:03:45.991,off_ence,this_connector,s3,television_trace,true,2019-03-22 18:49:12.833910,true | ||
aft_gleeful,2023-05-18 15:57:06.879000,intimation_awkwardly,test,s3,obtained_willow,true,2020-05-18 18:13:43.563198,false |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
id,_fivetran_synced,account_id,created_at,name,region | ||
ups_trampoline,2021-03-12 20:20:40.650,1k56c2c4xlti6_acct,2019-07-09 07:21:03.935607,s_test,us-test | ||
television_trace,2021-03-12 20:20:40.624,1k56c2c4xlti6_acct,2019-07-10 08:07:48.374015,s_gcp,us-test | ||
television_trace,2021-03-12 20:20:40.624,1k56c2c4xlti6_acct,2019-07-10 08:07:48.374015,s_gcp,us-test | ||
obtained_willow,2023-05-18 15:55:02.025000,1k56c2c4xlti6_acc,2020-05-18 17:28:42.535908,dbt_package_testing_bigquery,us-test |
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 |
---|---|---|
|
@@ -23,9 +23,10 @@ H6AsShJjRoy1n75oVRxjQ08perA=,2021-12-09 14:26:29.814,2021-12-09 20:30:53.903,int | |
bCgsj8twLxBBhaiBN9N4S35grkI=,2021-12-09 14:26:29.744,2021-12-09 20:30:53.901,intrinsic_departed,INFO,"{""table"":""user_history""}",write_to_table_start,123,456abc | ||
UcIZasAY/eulDQF2SQM6Y5W83gU=,2021-12-09 14:26:29.719,2021-12-09 20:30:53.878,intrinsic_departed,INFO,"{""table"":""media_insights""}",write_to_table_start,123,456abc | ||
mm0QUb+ldnbSWknrBrF/v24YGvo=,2021-12-09 14:26:05.907,2021-12-09 20:30:53.778,intrinsic_departed,INFO,,sync_start,123,456abc | ||
Z/kZAi7u6DzO7UrZeWK/ZsAkbno=,2021-12-10 14:27:00.504,2021-12-10 20:30:53.959,intrinsic_departed,INFO,,sync_end,123,456abc | ||
Z/kZAi7u6DzO7UrZeWK/ZsAkbno=,2021-12-10 14:27:00.504,2021-12-10 20:30:53.959,intrinsic_departed,INFO,,sync_end,,456abc | ||
+IX63qGrDFPaTy9/6epjpppk4JI=,2021-12-10 14:26:41.875,2021-12-10 20:30:53.948,intrinsic_departed,INFO,"{""table"":""media_insights""}",write_to_table_end,123,456abc | ||
ZZLSXVYxirh8aKlgdCzo5fvd71g=,2021-12-10 14:26:42.029,2021-12-10 20:30:53.949,intrinsic_departed,INFO,"{""schema"":""instagram_business"",""count"":5,""operationType"":""REPLACED_OR_INSERTED"",""table"":""media_insights""}",records_modified,123,456abc | ||
D7UqnKYn6OT04HkUcPNjXA95ttI=,2021-12-10 14:26:29.719,2021-12-10 20:30:53.878,intrinsic_departed,INFO,"{""table"":""media_insights""}",write_to_table_start,123,456abc | ||
V3H62Gj5c6nB8bY+OdxMHvp/hNs=,2021-12-10 14:26:05.907,2021-12-10 20:30:53.778,intrinsic_departed,INFO,,sync_start,123,456abc | ||
jkLxnPUfQ/9mHaWCmxUQEhul8ZA=,2023-11-09 11:31:31.579000,2023-11-09 15:55:12.560000,protestations_mourned,INFO,"{""actor"":""[email protected]"",""properties"":{""endpoint"":""************"",""apiKey"":""************"",""customEvents"":[],""syncMode"":""AllEvents"",""isE2ETest"":false,""events"":[],""customEventSyncMode"":""AllEvents""},""id"":""iterable""}",create_connector,, | ||
jkLxnPUfQ/9mHaWCmxUQEhul8ZA=,2023-11-09 11:31:31.579000,2023-11-09 15:55:12.560000,protestations_mourned,INFO,"{""actor"":""[email protected]"",""properties"":{""endpoint"":""************"",""apiKey"":""************"",""customEvents"":[],""syncMode"":""AllEvents"",""isE2ETest"":false,""events"":[],""customEventSyncMode"":""AllEvents""},""id"":""iterable""}",create_connector,, | ||
R7UqnKYn6OT04HkUcPNjXA95qqI=,2021-12-10 16:26:29.719,2021-12-10 20:30:53.878,intrinsic_departed,INFO,says actor but not a json,status,,456abc |
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,42 @@ | ||
{% macro fivetran_log_json_parse(string, string_path) -%} | ||
|
||
{{ adapter.dispatch('fivetran_log_json_parse', 'fivetran_log') (string, string_path) }} | ||
|
||
{%- endmacro %} | ||
|
||
{% macro default__fivetran_log_json_parse(string, string_path) %} | ||
|
||
{{ fivetran_utils.json_parse(string=string, string_path=string_path) }} | ||
|
||
{% endmacro %} | ||
|
||
{% macro snowflake__fivetran_log_json_parse(string, string_path) %} | ||
|
||
try_parse_json({{ string }}) {%- for s in string_path -%}{% if s is number %}[{{ s }}]{% else %}['{{ s }}']{% endif %}{%- endfor -%} | ||
|
||
{% endmacro %} | ||
|
||
{% macro redshift__fivetran_log_json_parse(string, string_path) %} | ||
|
||
json_extract_path_text( | ||
{{ string }}, | ||
{%- for s in string_path -%}'{{ s }}'{%- if not loop.last -%},{%- endif -%}{%- endfor -%}, | ||
true ) -- this flag sets null_if_invalid=true | ||
|
||
{% endmacro %} | ||
|
||
{% macro postgres__fivetran_log_json_parse(string, string_path) %} | ||
|
||
case when {{ string }} ~ '^\s*[\{].*[\}]?\s*$' -- Postgres has no native json check, so this will check the string for indicators of a JSON object | ||
then {{ string }}::json #>> '{ {%- for s in string_path -%}{{ s }}{%- if not loop.last -%},{%- endif -%}{%- endfor -%} }' | ||
else null end | ||
|
||
{% endmacro %} | ||
|
||
{% macro sqlserver__fivetran_log_json_parse(string, string_path) %} | ||
|
||
case when isjson({{ string }}) = 1 -- check if json string is valid | ||
then json_value({{ string }}, '$.{%- for s in string_path -%}{{ s }}{%- if not loop.last -%}.{%- endif -%}{%- endfor -%} ') | ||
else null end | ||
|
||
{% endmacro %} |
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,35 @@ | ||
{% macro fivetran_log_lookback(from_date, datepart='day', interval=7, default_start_date='2010-01-01') %} | ||
|
||
{{ adapter.dispatch('fivetran_log_lookback', 'fivetran_log') (from_date, datepart='day', interval=7, default_start_date='2010-01-01') }} | ||
|
||
{%- endmacro %} | ||
|
||
{% macro default__fivetran_log_lookback(from_date, datepart='day', interval=7, default_start_date='2010-01-01') %} | ||
|
||
coalesce( | ||
(select {{ dbt.dateadd(datepart=datepart, interval=-interval, from_date_or_timestamp=from_date) }} | ||
from {{ this }}), | ||
{{ "'" ~ default_start_date ~ "'" }} | ||
) | ||
|
||
{% endmacro %} | ||
|
||
{% macro bigquery__fivetran_log_lookback(from_date, datepart='day', interval=7, default_start_date='2010-01-01') %} | ||
|
||
-- Capture the latest timestamp in a call statement instead of a subquery for optimizing BQ costs on incremental runs | ||
{%- call statement('date_agg', fetch_result=True) -%} | ||
select {{ from_date }} from {{ this }} | ||
{%- endcall -%} | ||
|
||
-- load the result from the above query into a new variable | ||
{%- set query_result = load_result('date_agg') -%} | ||
|
||
-- the query_result is stored as a dataframe. Therefore, we want to now store it as a singular value. | ||
{%- set date_agg = query_result['data'][0][0] %} | ||
|
||
coalesce( | ||
{{ dbt.dateadd(datepart='day', interval=-7, from_date_or_timestamp="'" ~ date_agg ~ "'") }}, | ||
{{ "'" ~ default_start_date ~ "'" }} | ||
) | ||
|
||
{% endmacro %} | ||
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved
Hide resolved
|
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
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.
This may be a strange question, but what scenario would we need a default_start_date? Shouldn't there always by a
max(date)
on incremental runs? What scenario would there be where we need the coalesce to select the default start date?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.
Good point. I trialed removing this and it seems to compile and run fine. However for now I will leave this pending discussion on Tuesday.
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.
Thanks, I just wanted to make sure there likely wouldn't be a scenario where this field would actually be
null
. I don't believe including it will hurt so I am comfortable leaving it in.