From 52c289c47c2467f09dea2a917dd530b4d4ef889a Mon Sep 17 00:00:00 2001 From: Thomas Lento Date: Tue, 12 Dec 2023 09:05:49 -0800 Subject: [PATCH 1/2] Switch SCD example to entity type `natural` We recommend using the `natural` type for what is normally the `primary` entity in an SCD semantic model layout. The distinction is that `primary` indicates one row per entity value, while `natural` does not, and in an SCD context there is one row per entity value/time window set, rather than one row per entity value as in standard conformed dimension tables. --- website/docs/docs/build/dimensions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/docs/build/dimensions.md b/website/docs/docs/build/dimensions.md index 683ff730d3c..97e2fdd502e 100644 --- a/website/docs/docs/build/dimensions.md +++ b/website/docs/docs/build/dimensions.md @@ -252,7 +252,7 @@ This example shows how to create slowly changing dimensions (SCD) using a semant | 333 | 2 | 2020-08-19 | 2021-10-22| | 333 | 3 | 2021-10-22 | 2048-01-01| -Take note of the extra arguments under `validity_params`: `is_start` and `is_end`. These arguments indicate the columns in the SCD table that contain the start and end dates for each tier (or beginning or ending timestamp column for a dimensional value). +Take note of the extra arguments under `validity_params`: `is_start` and `is_end`. These arguments indicate the columns in the SCD table that contain the start and end dates for each tier (or beginning or ending timestamp column for a dimensional value). Note also the entity is tagged as `natural` - this is to distinguish it from a `primary` entity, where we expect one row per entity value. Here, we expect one row per entity value/validity window combination. ```yaml semantic_models: @@ -282,7 +282,7 @@ semantic_models: entities: - name: sales_person - type: primary + type: natural expr: sales_person_id ``` From 62def67a0d548d3bca1609acdfe62f61bf023876 Mon Sep 17 00:00:00 2001 From: Thomas Lento Date: Tue, 12 Dec 2023 09:34:06 -0800 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: mirnawong1 <89008547+mirnawong1@users.noreply.github.com> --- website/docs/docs/build/dimensions.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/website/docs/docs/build/dimensions.md b/website/docs/docs/build/dimensions.md index 97e2fdd502e..3c4edd9aef0 100644 --- a/website/docs/docs/build/dimensions.md +++ b/website/docs/docs/build/dimensions.md @@ -252,7 +252,8 @@ This example shows how to create slowly changing dimensions (SCD) using a semant | 333 | 2 | 2020-08-19 | 2021-10-22| | 333 | 3 | 2021-10-22 | 2048-01-01| -Take note of the extra arguments under `validity_params`: `is_start` and `is_end`. These arguments indicate the columns in the SCD table that contain the start and end dates for each tier (or beginning or ending timestamp column for a dimensional value). Note also the entity is tagged as `natural` - this is to distinguish it from a `primary` entity, where we expect one row per entity value. Here, we expect one row per entity value/validity window combination. + +The `validity_params` include two important arguments — `is_start` and `is_end`. These specify the columns in the SCD table that mark the start and end dates (or timestamps) for each tier or dimension. Additionally, the entity is tagged as `natural` to differentiate it from a `primary` entity. In a `primary` entity, each entity value has one row. In contrast, a `natural` entity has one row for each combination of entity value and its validity period. ```yaml semantic_models: @@ -280,6 +281,8 @@ semantic_models: - name: tier type: categorical + primary_entity: sales_person + entities: - name: sales_person type: natural