-
Notifications
You must be signed in to change notification settings - Fork 21
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/date not recognized #54
Changes from 6 commits
2ea8406
f3c4332
721f3f5
fb30efc
64e2eb6
7e3216e
cf87000
a8ac480
e705311
7fb52a0
b488982
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{{ config( | ||
tags="fivetran_validations", | ||
enabled=var('fivetran_validation_tests_enabled', false) | ||
) }} | ||
|
||
with prod as ( | ||
select * | ||
from {{ target.schema }}_xero_prod.xero__balance_sheet_report | ||
), | ||
|
||
dev as ( | ||
select * | ||
from {{ target.schema }}_xero_dev.xero__balance_sheet_report | ||
), | ||
|
||
prod_not_in_dev as ( | ||
-- rows from prod not found in dev | ||
select * from prod | ||
except distinct | ||
select * from dev | ||
), | ||
|
||
dev_not_in_prod as ( | ||
-- rows from dev not found in prod | ||
select * from dev | ||
except distinct | ||
select * from prod | ||
), | ||
|
||
final as ( | ||
select | ||
*, | ||
'from prod' as source | ||
from prod_not_in_dev | ||
|
||
union all -- union since we only care if rows are produced | ||
|
||
select | ||
*, | ||
'from dev' as source | ||
from dev_not_in_prod | ||
) | ||
|
||
select * | ||
from final |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{{ config( | ||
tags="fivetran_validations", | ||
enabled=var('fivetran_validation_tests_enabled', false) | ||
) }} | ||
|
||
with prod as ( | ||
select * | ||
from {{ target.schema }}_xero_prod.xero__general_ledger | ||
), | ||
|
||
dev as ( | ||
select * | ||
from {{ target.schema }}_xero_dev.xero__general_ledger | ||
), | ||
|
||
prod_not_in_dev as ( | ||
-- rows from prod not found in dev | ||
select * from prod | ||
except distinct | ||
select * from dev | ||
), | ||
|
||
dev_not_in_prod as ( | ||
-- rows from dev not found in prod | ||
select * from dev | ||
except distinct | ||
select * from prod | ||
), | ||
|
||
final as ( | ||
select | ||
*, | ||
'from prod' as source | ||
from prod_not_in_dev | ||
|
||
union all -- union since we only care if rows are produced | ||
|
||
select | ||
*, | ||
'from dev' as source | ||
from dev_not_in_prod | ||
) | ||
|
||
select * | ||
from final |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{{ config( | ||
tags="fivetran_validations", | ||
enabled=var('fivetran_validation_tests_enabled', false) | ||
) }} | ||
|
||
with prod as ( | ||
select * | ||
from {{ target.schema }}_xero_prod.xero__invoice_line_items | ||
), | ||
|
||
dev as ( | ||
select * | ||
from {{ target.schema }}_xero_dev.xero__invoice_line_items | ||
), | ||
|
||
prod_not_in_dev as ( | ||
-- rows from prod not found in dev | ||
select * from prod | ||
except distinct | ||
select * from dev | ||
), | ||
|
||
dev_not_in_prod as ( | ||
-- rows from dev not found in prod | ||
select * from dev | ||
except distinct | ||
select * from prod | ||
), | ||
|
||
final as ( | ||
select | ||
*, | ||
'from prod' as source | ||
from prod_not_in_dev | ||
|
||
union all -- union since we only care if rows are produced | ||
|
||
select | ||
*, | ||
'from dev' as source | ||
from dev_not_in_prod | ||
) | ||
|
||
select * | ||
from final |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{{ config( | ||
tags="fivetran_validations", | ||
enabled=var('fivetran_validation_tests_enabled', false) | ||
) }} | ||
|
||
with prod as ( | ||
select * | ||
from {{ target.schema }}_xero_prod.xero__profit_and_loss_report | ||
), | ||
|
||
dev as ( | ||
select * | ||
from {{ target.schema }}_xero_dev.xero__profit_and_loss_report | ||
), | ||
|
||
prod_not_in_dev as ( | ||
-- rows from prod not found in dev | ||
select * from prod | ||
except distinct | ||
select * from dev | ||
), | ||
|
||
dev_not_in_prod as ( | ||
-- rows from dev not found in prod | ||
select * from dev | ||
except distinct | ||
select * from prod | ||
), | ||
|
||
final as ( | ||
select | ||
*, | ||
'from prod' as source | ||
from prod_not_in_dev | ||
|
||
union all -- union since we only care if rows are produced | ||
|
||
select | ||
*, | ||
'from dev' as source | ||
from dev_not_in_prod | ||
) | ||
|
||
select * | ||
from final |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additionally, I noticed that fields like account_class or source_type have all-caps values... should we do the same with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per conversation with @fivetran-joemarkiewicz, this is the source behavior, so we'll keep as is. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,21 +10,35 @@ with calendar as ( | |
|
||
), organization as ( | ||
|
||
select * | ||
select | ||
*, | ||
cast(extract(year from current_date) as {{ dbt.type_string() }}) as current_year, | ||
cast(extract(year from {{ dbt.dateadd('year', 1, 'current_date') }}) as {{ dbt.type_string() }}) as next_year | ||
from {{ var('organization') }} | ||
|
||
|
||
), year_end as ( | ||
|
||
-- Calculate the current financial year-end date for each organization: | ||
-- For February, determine last day by subtracting 1 day from March 1, avoiding leap year logic. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Brilliant! |
||
-- Compare the year end date to the current date: | ||
-- Use this year's date if it's on or after the current date. | ||
-- Otherwise, use the next year's corresponding date. | ||
select | ||
case | ||
when cast(extract(year from current_date) || '-' || financial_year_end_month || '-' || financial_year_end_day as date) >= current_date | ||
then cast(extract(year from current_date) || '-' || financial_year_end_month || '-' || financial_year_end_day as date) | ||
else case when financial_year_end_month = 2 and financial_year_end_day = 29 | ||
then cast(extract(year from {{ dbt.dateadd('year', -1, 'current_date') }}) || '-' || financial_year_end_month || '-28' as date) -- Necessary for organizations with a reported fiscal year end of 02-29 as the previous year will not be a leap year and must be the 28th. | ||
else cast(extract(year from {{ dbt.dateadd('year', -1, 'current_date') }}) || '-' || financial_year_end_month || '-' || financial_year_end_day as date) | ||
end | ||
end as current_year_end_date, | ||
source_relation | ||
source_relation, | ||
case when financial_year_end_month = 2 and financial_year_end_day = 29 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving this condition first appears to prevent the warehouse from trying to execute the other nested conditions that cause the error. |
||
then | ||
case when cast({{ dbt.dateadd('day', -1, "cast(current_year || '-03-01' as date)") }} as date) >= current_date | ||
then cast({{ dbt.dateadd('day', -1, "cast(current_year || '-03-01' as date)") }} as date) | ||
else cast({{ dbt.dateadd('day', -1, "cast(next_year || '-03-01' as date)") }} as date) | ||
end | ||
else | ||
case when cast(current_year || '-' || financial_year_end_month || '-' || financial_year_end_day as date) >= current_date | ||
then cast(current_year || '-' || financial_year_end_month || '-' || financial_year_end_day as date) | ||
else cast(next_year || '-' || financial_year_end_month || '-' || financial_year_end_day as date) | ||
end | ||
end as current_year_end_date | ||
|
||
from organization | ||
|
||
), joined as ( | ||
|
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.
Is this a necessary file? If not, can we remove it.
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.
Nope--removed!