From 31322675a9aba1fcd24e1d2622c70fd216ba6900 Mon Sep 17 00:00:00 2001 From: Jordan Stein Date: Thu, 26 Sep 2024 15:50:48 -0700 Subject: [PATCH] custom grain --- models/marts/_models.yml | 5 ++++- models/marts/time_spine.sql | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/models/marts/_models.yml b/models/marts/_models.yml index 7d855c6..9c86054 100644 --- a/models/marts/_models.yml +++ b/models/marts/_models.yml @@ -2,6 +2,9 @@ models: - name: time_spine time_spine: standard_granularity_column: date_day # column for the standard grain of your table + custom_granularities: + - name: fiscal_quarter columns: - name: date_day - granularity: day # set granularity at column-level for standard_granularity_column \ No newline at end of file + granularity: day # set granularity at column-level for standard_granularity_column + - name: fiscal_quarter \ No newline at end of file diff --git a/models/marts/time_spine.sql b/models/marts/time_spine.sql index cb61284..5381fe5 100644 --- a/models/marts/time_spine.sql +++ b/models/marts/time_spine.sql @@ -12,7 +12,8 @@ days as ( cast_to_date as ( select - cast(date_day as date) as date_day + cast(date_day as date) as date_day, + date_trunc('quarter', date_day) as fiscal_quarter from days