Merged PR 3455: Cleans old Xero KPIs models
# Description Cleans Xero models for the old KPIs flow, temporary tests and schema entries # Checklist - [X] The edited models and dependants run properly with production data. - [NA] The edited models are sufficiently documented. - [X] The edited models contain PK tests, and I've ran and passed them. - [NA] I have checked for DRY opportunities with other models and docs. - [NA] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #23760
This commit is contained in:
parent
8c23f91242
commit
38c7cc10df
5 changed files with 0 additions and 684 deletions
|
|
@ -1,80 +0,0 @@
|
|||
{% set min_date = "2022-01-01" %}
|
||||
{% set dimensions = ("global", "by_billing_country") %}
|
||||
-- "by_number_of_listings" excluded on purpose - there's differences because of daily
|
||||
-- segmentation
|
||||
with
|
||||
new_mtd_host_resolutions as (
|
||||
select
|
||||
end_date as date,
|
||||
dimension,
|
||||
dimension_value,
|
||||
xero_host_resolution_amount_paid_in_gbp,
|
||||
xero_host_resolution_payment_count
|
||||
from {{ ref("int_kpis__agg_mtd_host_resolutions") }}
|
||||
where
|
||||
end_date >= '{{ min_date }}'
|
||||
and dimension in {{ dimensions }}
|
||||
and dimension_value <> 'UNSET'
|
||||
),
|
||||
new_monthly_host_resolutions as (
|
||||
select
|
||||
end_date as date,
|
||||
dimension,
|
||||
dimension_value,
|
||||
xero_host_resolution_amount_paid_in_gbp,
|
||||
xero_host_resolution_payment_count
|
||||
from {{ ref("int_kpis__agg_monthly_host_resolutions") }}
|
||||
where
|
||||
end_date >= '{{ min_date }}'
|
||||
and dimension in {{ dimensions }}
|
||||
and dimension_value <> 'UNSET'
|
||||
),
|
||||
new_host_resolutions as (
|
||||
select *
|
||||
from new_mtd_host_resolutions
|
||||
union all
|
||||
select *
|
||||
from new_monthly_host_resolutions
|
||||
),
|
||||
old_host_resolutions as (
|
||||
select
|
||||
date,
|
||||
dimension,
|
||||
dimension_value,
|
||||
xero_host_resolution_amount_paid_in_gbp,
|
||||
xero_host_resolution_payment_count
|
||||
from {{ ref("int_xero__mtd_invoicing_metrics") }}
|
||||
where date >= '{{ min_date }}' and dimension in {{ dimensions }}
|
||||
),
|
||||
comparison as (
|
||||
select
|
||||
coalesce(o.date, n.date) as date,
|
||||
coalesce(o.dimension, n.dimension) as dimension,
|
||||
coalesce(o.dimension_value, n.dimension_value) as dimension_value,
|
||||
o.xero_host_resolution_amount_paid_in_gbp
|
||||
as old_xero_host_resolution_amount_paid_in_gbp,
|
||||
n.xero_host_resolution_amount_paid_in_gbp
|
||||
as new_xero_host_resolution_amount_paid_in_gbp,
|
||||
coalesce(o.xero_host_resolution_amount_paid_in_gbp, 0) - coalesce(
|
||||
n.xero_host_resolution_amount_paid_in_gbp, 0
|
||||
) as diff_xero_host_resolution_amount_paid_in_gbp,
|
||||
o.xero_host_resolution_payment_count
|
||||
as old_xero_host_resolution_payment_count,
|
||||
n.xero_host_resolution_payment_count
|
||||
as new_xero_host_resolution_payment_count,
|
||||
coalesce(o.xero_host_resolution_payment_count, 0) - coalesce(
|
||||
n.xero_host_resolution_payment_count, 0
|
||||
) as diff_xero_host_resolution_payment_count
|
||||
from old_host_resolutions o
|
||||
full outer join
|
||||
new_host_resolutions n
|
||||
on o.date = n.date
|
||||
and o.dimension = n.dimension
|
||||
and o.dimension_value = n.dimension_value
|
||||
)
|
||||
select *
|
||||
from comparison
|
||||
where
|
||||
diff_xero_host_resolution_amount_paid_in_gbp <> 0
|
||||
or diff_xero_host_resolution_payment_count <> 0
|
||||
order by date desc
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
{% set min_date = "2022-01-01" %}
|
||||
{% set dimensions = ("global", "by_billing_country") %}
|
||||
-- "by_number_of_listings" excluded on purpose - there's differences because of daily
|
||||
-- segmentation
|
||||
with
|
||||
new_mtd_invoiced_revenue as (
|
||||
select
|
||||
end_date as date,
|
||||
dimension,
|
||||
dimension_value,
|
||||
xero_booking_net_fees_in_gbp,
|
||||
xero_listing_net_fees_in_gbp,
|
||||
xero_verification_net_fees_in_gbp,
|
||||
xero_operator_net_fees_in_gbp,
|
||||
xero_waiver_paid_back_to_host_in_gbp,
|
||||
xero_e_deposit_net_fees_in_gbp,
|
||||
xero_guesty_net_fees_in_gbp,
|
||||
xero_apis_net_fees_in_gbp
|
||||
from {{ ref("int_kpis__agg_mtd_invoiced_revenue") }}
|
||||
where
|
||||
end_date >= '{{ min_date }}'
|
||||
and dimension in {{ dimensions }}
|
||||
and dimension_value <> 'UNSET'
|
||||
),
|
||||
new_monthly_invoiced_revenue as (
|
||||
select
|
||||
end_date as date,
|
||||
dimension,
|
||||
dimension_value,
|
||||
xero_booking_net_fees_in_gbp,
|
||||
xero_listing_net_fees_in_gbp,
|
||||
xero_verification_net_fees_in_gbp,
|
||||
xero_operator_net_fees_in_gbp,
|
||||
xero_waiver_paid_back_to_host_in_gbp,
|
||||
xero_e_deposit_net_fees_in_gbp,
|
||||
xero_guesty_net_fees_in_gbp,
|
||||
xero_apis_net_fees_in_gbp
|
||||
from {{ ref("int_kpis__agg_monthly_invoiced_revenue") }}
|
||||
where
|
||||
end_date >= '{{ min_date }}'
|
||||
and dimension in {{ dimensions }}
|
||||
and dimension_value <> 'UNSET'
|
||||
),
|
||||
new_invoiced_revenue as (
|
||||
select *
|
||||
from new_mtd_invoiced_revenue
|
||||
union all
|
||||
select *
|
||||
from new_monthly_invoiced_revenue
|
||||
),
|
||||
old_invoiced_revenue as (
|
||||
select
|
||||
date,
|
||||
dimension,
|
||||
dimension_value,
|
||||
xero_booking_net_fees_in_gbp,
|
||||
xero_listing_net_fees_in_gbp,
|
||||
xero_verification_net_fees_in_gbp,
|
||||
xero_operator_net_fees_in_gbp,
|
||||
xero_waiver_paid_back_to_host_in_gbp,
|
||||
xero_e_deposit_net_fees_in_gbp,
|
||||
xero_guesty_net_fees_in_gbp,
|
||||
xero_apis_net_fees_in_gbp
|
||||
from {{ ref("int_xero__mtd_invoicing_metrics") }}
|
||||
where date >= '{{ min_date }}' and dimension in {{ dimensions }}
|
||||
),
|
||||
comparison as (
|
||||
select
|
||||
coalesce(o.date, n.date) as date,
|
||||
coalesce(o.dimension, n.dimension) as dimension,
|
||||
coalesce(o.dimension_value, n.dimension_value) as dimension_value,
|
||||
o.xero_booking_net_fees_in_gbp as old_xero_booking_net_fees_in_gbp,
|
||||
n.xero_booking_net_fees_in_gbp as new_xero_booking_net_fees_in_gbp,
|
||||
coalesce(o.xero_booking_net_fees_in_gbp, 0) - coalesce(
|
||||
n.xero_booking_net_fees_in_gbp, 0
|
||||
) as diff_xero_booking_net_fees_in_gbp,
|
||||
|
||||
o.xero_listing_net_fees_in_gbp as old_xero_listing_net_fees_in_gbp,
|
||||
n.xero_listing_net_fees_in_gbp as new_xero_listing_net_fees_in_gbp,
|
||||
coalesce(o.xero_listing_net_fees_in_gbp, 0) - coalesce(
|
||||
n.xero_listing_net_fees_in_gbp, 0
|
||||
) as diff_xero_listing_net_fees_in_gbp,
|
||||
|
||||
o.xero_verification_net_fees_in_gbp
|
||||
as old_xero_verification_net_fees_in_gbp,
|
||||
n.xero_verification_net_fees_in_gbp
|
||||
as new_xero_verification_net_fees_in_gbp,
|
||||
coalesce(o.xero_verification_net_fees_in_gbp, 0) - coalesce(
|
||||
n.xero_verification_net_fees_in_gbp, 0
|
||||
) as diff_xero_verification_net_fees_in_gbp,
|
||||
|
||||
o.xero_operator_net_fees_in_gbp as old_xero_operator_net_fees_in_gbp,
|
||||
n.xero_operator_net_fees_in_gbp as new_xero_operator_net_fees_in_gbp,
|
||||
coalesce(o.xero_operator_net_fees_in_gbp, 0) - coalesce(
|
||||
n.xero_operator_net_fees_in_gbp, 0
|
||||
) as diff_xero_operator_net_fees_in_gbp,
|
||||
|
||||
o.xero_waiver_paid_back_to_host_in_gbp
|
||||
as old_xero_waiver_paid_back_to_host_in_gbp,
|
||||
n.xero_waiver_paid_back_to_host_in_gbp
|
||||
as new_xero_waiver_paid_back_to_host_in_gbp,
|
||||
coalesce(o.xero_waiver_paid_back_to_host_in_gbp, 0) - coalesce(
|
||||
n.xero_waiver_paid_back_to_host_in_gbp, 0
|
||||
) as diff_xero_waiver_paid_back_to_host_in_gbp,
|
||||
|
||||
o.xero_e_deposit_net_fees_in_gbp as old_xero_e_deposit_net_fees_in_gbp,
|
||||
n.xero_e_deposit_net_fees_in_gbp as new_xero_e_deposit_net_fees_in_gbp,
|
||||
coalesce(o.xero_e_deposit_net_fees_in_gbp, 0) - coalesce(
|
||||
n.xero_e_deposit_net_fees_in_gbp, 0
|
||||
) as diff_xero_e_deposit_net_fees_in_gbp,
|
||||
|
||||
o.xero_guesty_net_fees_in_gbp as old_xero_guesty_net_fees_in_gbp,
|
||||
n.xero_guesty_net_fees_in_gbp as new_xero_guesty_net_fees_in_gbp,
|
||||
coalesce(o.xero_guesty_net_fees_in_gbp, 0) - coalesce(
|
||||
n.xero_guesty_net_fees_in_gbp, 0
|
||||
) as diff_xero_guesty_net_fees_in_gbp,
|
||||
|
||||
o.xero_apis_net_fees_in_gbp as old_xero_apis_net_fees_in_gbp,
|
||||
n.xero_apis_net_fees_in_gbp as new_xero_apis_net_fees_in_gbp,
|
||||
coalesce(o.xero_apis_net_fees_in_gbp, 0)
|
||||
- coalesce(n.xero_apis_net_fees_in_gbp, 0) as diff_xero_apis_net_fees_in_gbp
|
||||
|
||||
from old_invoiced_revenue o
|
||||
full outer join
|
||||
new_invoiced_revenue n
|
||||
on o.date = n.date
|
||||
and o.dimension = n.dimension
|
||||
and o.dimension_value = n.dimension_value
|
||||
)
|
||||
select *
|
||||
from comparison
|
||||
where
|
||||
diff_xero_apis_net_fees_in_gbp <> 0
|
||||
or diff_xero_guesty_net_fees_in_gbp <> 0
|
||||
or diff_xero_e_deposit_net_fees_in_gbp <> 0
|
||||
or diff_xero_waiver_paid_back_to_host_in_gbp <> 0
|
||||
or diff_xero_operator_net_fees_in_gbp <> 0
|
||||
or diff_xero_verification_net_fees_in_gbp <> 0
|
||||
or diff_xero_listing_net_fees_in_gbp <> 0
|
||||
or diff_xero_booking_net_fees_in_gbp <> 0
|
||||
order by date desc
|
||||
Loading…
Add table
Add a link
Reference in a new issue