Merged PR 2519: mtd bookings with 2 dimensions
# Description This is a first idea of how I'd like to add dimensionality in the KPIs for the mtd models. For the moment, I keep deal_id apart, so I just touch the "mtd" models, that so far only contained "global" metrics. In this case I include the listing segmentation (0, 1-5, 6-20, etc) in the bookings. To do this, I created 2 new fields: dimension and dimension_values. I also created a "master" table with `date` - `dimension` - `dimension_value` called `int_dates_mtd_by_dimension` Important notes: - I force a hardcode in `int_mtd_vs_previous_year_metrics`. This is to not break production. - You will notice how repetitive the code is starting to look. My intention with this PR is that we are happy with this approach on the naming, the strategy for joins, etc. If that's ok, next step is going to be doing macros on top. Think of the state of `int_core__mtd_booking_metrics` as the "compiled version" of the macro that should come afterwards. # Checklist - [X] The edited models and dependants run properly with production data. - [X] The edited models are sufficiently documented. - [X] The edited models contain PK tests, and I've ran and passed them. - [ ] I have checked for DRY opportunities with other models and docs. - [X] 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: #19325
This commit is contained in:
parent
7177b41e19
commit
afc20f0e20
5 changed files with 289 additions and 18 deletions
|
|
@ -424,5 +424,92 @@ models:
|
|||
- name: id_deal
|
||||
data_type: character varying
|
||||
description: Id of the deal associated to the host.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: int_dates_mtd_by_dimension
|
||||
description: |
|
||||
This model provides Month-To-Date (MTD) necessary dates, dimension and dimension_values
|
||||
for MTD-based models to work.
|
||||
It provides the basic "empty" structure from which metrics will be built upon. This is, on
|
||||
top of the Date that characterises int_dates_mtd, including the dimensions and their
|
||||
respective values that should appear in any mtd metric model.
|
||||
|
||||
Example:
|
||||
- For the "global" dimension, we will only have the "global" dimension value.
|
||||
- For the "by_number_of_listing" dimension, we will have different values
|
||||
according to the segments defined, ex: 0, 1-5, 6-20, etc.
|
||||
|
||||
... and so on and forth for any available dimension. These combinations should appear
|
||||
for each date of the MTD models.
|
||||
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- date
|
||||
- dimension
|
||||
- dimension_value
|
||||
|
||||
columns:
|
||||
- name: year
|
||||
data_type: int
|
||||
description: Year number of the given date.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: month
|
||||
data_type: int
|
||||
description: Month number of the given date.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: day
|
||||
data_type: int
|
||||
description: Day monthly number of the given date.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: is_end_of_month
|
||||
data_type: boolean
|
||||
description: Is end of month, 1 for yes, 0 for no.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: is_current_month
|
||||
data_type: boolean
|
||||
description: |
|
||||
Checks if the date is within the current executed month,
|
||||
1 for yes, 0 for no.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: first_day_month
|
||||
data_type: date
|
||||
description: |
|
||||
First day of the month correspoding to the date field.
|
||||
It comes from int_dates_mtd logic.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: date
|
||||
data_type: date
|
||||
description: |
|
||||
Main date for the computation, metrics include monthly information
|
||||
until this date.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: dimension
|
||||
data_type: string
|
||||
description: The dimension or granularity of the metrics.
|
||||
tests:
|
||||
- accepted_values:
|
||||
values:
|
||||
- global
|
||||
- by_number_of_listings
|
||||
|
||||
- name: dimension_value
|
||||
data_type: string
|
||||
description: The value or segment available for the selected dimension.
|
||||
tests:
|
||||
- not_null
|
||||
Loading…
Add table
Add a link
Reference in a new issue