Merged PR 3967: Adds an "All History" time window to Account Margin
# Description Quick improvement to be able to report the same setup of metrics by considering all account history up to a certain date. It adds a new computation flow for this All History window. Note that I needed to update the macro to override this case by using unbounded preceding. I also took the opportunity to update the exposures of the new report. # 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. - [X] 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: #26085
This commit is contained in:
parent
f5e417c7db
commit
0ec1484846
5 changed files with 136 additions and 2 deletions
|
|
@ -3,6 +3,8 @@ This macro calculates the aggregation of a metric over a partition of a column,
|
|||
ordered by another column, with a window of x and y preceeding rows.
|
||||
|
||||
It's designed to be placed within a SELECT statement.
|
||||
|
||||
If include_all_history is True, then X is ignored.
|
||||
*/
|
||||
{% macro calculate_aggregation_between_preceeding_x_and_y(
|
||||
metric,
|
||||
|
|
@ -10,10 +12,18 @@ It's designed to be placed within a SELECT statement.
|
|||
partition_by="id_deal",
|
||||
order_by="date",
|
||||
x=12,
|
||||
y=1
|
||||
y=1,
|
||||
include_all_history=False
|
||||
) %}
|
||||
{{ aggregation }} ({{ metric }}) over (
|
||||
partition by {{ partition_by }}
|
||||
order by {{ order_by }} rows between {{ x }} preceding and {{ y }} preceding
|
||||
order by
|
||||
{{ order_by }} rows between
|
||||
{% if include_all_history %}
|
||||
unbounded preceding
|
||||
{% else %}
|
||||
{{ x }} preceding
|
||||
{% endif %}
|
||||
and {{ y }} preceding
|
||||
) as {{ aggregation }}_{{ metric }}
|
||||
{% endmacro %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue