-
Notifications
You must be signed in to change notification settings - Fork 24
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/postgres performance #126
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
44248c9
patch/update-macro-readme
fivetran-catfritz 2007a03
bug/postgres-performance
fivetran-catfritz c2cbfa9
remove int model
fivetran-catfritz ae6714a
remove int model
fivetran-catfritz 3eb39f3
switch to jsonb
fivetran-catfritz 0dbc4bc
add limit for test
fivetran-catfritz 0cd0c02
update changelog and regen docs
fivetran-catfritz eb9560c
Update README.md
5tran-alexil b1b35c1
Merge branch 'bug/postgres-performance' into patch/update-macro-readme
fivetran-catfritz 854f145
Merge pull request #115 from fivetran/patch/update-macro-readme
fivetran-catfritz c05251d
Update CHANGELOG.md
fivetran-catfritz 51ee14c
Merge pull request #127 from fivetran/5tran-alexil-patch-2
fivetran-catfritz fb1ae0f
Update CHANGELOG.md
fivetran-catfritz 4daf0c9
Update CHANGELOG.md
fivetran-catfritz 4cb02d0
Update CHANGELOG.md
fivetran-catfritz 38cbdba
Update CHANGELOG.md
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
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
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,35 +1,18 @@ | ||
{% macro fivetran_log_lookback(from_date, datepart='day', interval=7, default_start_date='2010-01-01') %} | ||
{% macro fivetran_log_lookback(from_date, datepart='day', interval=7, safety_date='2010-01-01') %} | ||
|
||
{{ adapter.dispatch('fivetran_log_lookback', 'fivetran_log') (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, safety_date='2010-01-01') }} | ||
|
||
{%- endmacro %} | ||
|
||
{% macro default__fivetran_log_lookback(from_date, datepart='day', interval=7, default_start_date='2010-01-01') %} | ||
{% macro default__fivetran_log_lookback(from_date, datepart='day', interval=7, safety_date='2010-01-01') %} | ||
|
||
coalesce( | ||
(select {{ dbt.dateadd(datepart=datepart, interval=-interval, from_date_or_timestamp=from_date) }} | ||
from {{ this }}), | ||
{{ "'" ~ default_start_date ~ "'" }} | ||
) | ||
{% set sql_statement %} | ||
select coalesce({{ from_date }}, {{ "'" ~ safety_date ~ "'" }}) | ||
from {{ this }} | ||
{%- endset -%} | ||
|
||
{% endmacro %} | ||
{%- set result = dbt_utils.get_single_value(sql_statement) %} | ||
|
||
{% 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 ~ "'" }} | ||
) | ||
{{ dbt.dateadd(datepart=datepart, interval=-interval, from_date_or_timestamp="cast('" ~ result ~ "' as date)") }} | ||
|
||
{% 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
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 |
---|---|---|
|
@@ -34,4 +34,4 @@ final as ( | |
) | ||
|
||
select * | ||
from final | ||
from final |
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.
I know this is incredibly small, but we should call this out as a change in the CHANGELOG. Also, I am fairly certain this won't be breaking, but can you confirm that this datatype change won't cause any datatype changes for Postgres users? I tested myself and didn't see any issues when running prod then dev right after, but just want to double check.
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.
Added to under the hood. I also tested this and it would make sense there is no issue since the end results in either version are strings, and the cast to json is an intermediate step.