Skip to content
  • There are no suggestions because the search field is empty.

Snowflake Dimensional

Applies to
Platform: Snowflake
Architecture: Dimensional

Snowflake Dimensional generates a Stage and a dimensional Core for Snowflake as SnowSQL scripts with stored procedure loaders. Select the Generator Configuration Snowflake Dimensional when you add a project whose dimensional model runs on Snowflake.

Scope and output

  • Platform: Snowflake.
  • Dataflow Modeling columns: Source; Stage in the Bronze column; Entity, Fact and Core Composite in the Silver column Dimensional. See Understand the Layering concept.
  • Deployment layers: Stage, Cleanse with the source, deduplication and data quality views, and Core with the tables, loaders and result views.
  • Output: the layer scripts SQL\L010_Stage.sql, SQL\L020_Cleanse.sql and SQL\L030_Core.sql, the task scripts of the load control or an Airflow DAG in the folder LoadControl, and deploy.ps1 with deploy.sql, described in Snowflake - Artifacts.

Prerequisites

  • A Snowflake account with the databases of the layers and of the load control, and a warehouse. The deployment creates only the schemas.
  • A role that creates the objects, runs tasks and reads the source databases.
  • PowerShell 7 and SnowSQL with a named connection.

The setup is described in Snowflake - Target environment, the placeholders in Snowflake - Placeholder values.

Sources and linked projects

Stage source views read each source table as <database>.<schema>.<table>, with placeholders for the database and schema. Discover a Snowflake database creates the source model objects, and Source systems per generator configuration lists the discovery types.

You can import a linked project as a source and export this project as a linked project.

Supported model objects

Capabilities and limitations

  • Names: generated names are upper case without quotes, for example STG_ST_BDC_CUSTOMER.
  • Loaders: stored procedures <table name>_LOADER in Snowflake Scripting. Each loads in one transaction and logs its row counts with SYSTEM$LOG_INFO.
  • Tables: Implementation Type Cached creates a transient table, Permanent a permanent one.
  • Keys: an Entity table has the surrogate key <model object name>_SK INTEGER IDENTITY ORDER as primary key and a unique constraint on its business key terms. A Fact table has no primary key. Snowflake does not enforce them, see Overview of Constraints.
  • Foreign keys: Foreign Key Mode offers None and Create Disabled (default), not Create Enforced.
  • Indexes: index management is not available.
  • Unknown member: each Entity table gets a row with the surrogate key -1, and a Fact row without a matching Entity row references it. Custom Singleton Values sets its values.
  • Data quality: Entity and Fact support data quality rules.
  • Change detection: Delta Detection on the Entity sets how rows are compared; the default is Hash Value Comparison.
  • Hashing: row hashes are SHA2_BINARY(..., 256) in BINARY(32) columns with the default Hash Algorithm. See How biGENIUS-X builds hash values.
  • Validity: with Persist Validity on (default), historized tables store BG_ValidToTimestamp; with it off, the result view computes it.
  • Deployment: with the default Deployment Options, each deployment replaces the tables with empty ones and drops the load control schema. See Snowflake - Deployment.
  • Loading: LoadControl Options offers Snowflake tasks and Apache Airflow. Warehouse Placeholder Variable Name moves the tasks of a dataflow to another warehouse.
  • Governance: Apply Sensitivity Level Tags adds a script that creates the tag SENSITIVITY_LEVEL.

Project properties

The configuration offers these project properties, with their defaults:

Data types

The Default Terms get these data types. TIMESTAMP_TZ has no precision, so Snowflake uses precision 9, and VARCHAR has no length:

  • Timestamps, TIMESTAMP_TZ: BG_LoadTimestamp, BG_UpdateTimestamp, BG_ValidFromTimestamp, BG_ValidToTimestamp, BG_EffectiveTimestamp
  • Row hashes, BINARY(32): BG_RowHash, BG_RowHashScd1, BG_RowHashScd2
  • Text, VARCHAR: BG_SourceSystem, BG_DataflowName, BG_DataflowSetName, BG_ErrorDescription, BG_IncrementLoadStatus
  • Numbers, INTEGER: BG_ID, BG_ErrorCount, BG_DataQuality_ID, BG_Entity_Identity, BG_Entity_ForeignKey_Identity, BG_Fact_ForeignKey_Identity
  • Flags, BOOLEAN: BG_IsDeleted
  • BG_IncrementalFilter, BG_LowerThreshold, BG_UpperThreshold: the data type of the term that you map to BG_IncrementalFilter

Platform differences

The table compares the configuration with Microsoft SQL Server Dimensional of the same release:

ItemSnowflakeMicrosoft SQL Server
Timestamp Default TermsTIMESTAMP_TZdatetimeoffset
Hash Default TermsBINARY(32)binary(20)
Text Default TermsVARCHARnvarchar
Hash Algorithm defaultSHA2-256SHA1
Persist Validity defaultonoff
Deployment Options defaultboth optionsGenerate Drop Table Statements
Enforced foreign keysnot availableavailable
Index managementnot availableavailable
Deploy LoadControlnot availableavailable

On both platforms, LoadControl Options offers Airflow and a native load control: Snowflake tasks on Snowflake, Native Load Control on Microsoft SQL Server.

Example

An Entity bk_multipart_not_nullable with the business key terms BDC_SHOP_ID and BDC_CUSTOMER_ID1 generates this table and unknown-member row. The excerpt shows the example database DWH and schema CORE in place of the placeholders, leaves out the four descriptive columns and the transaction statements:

CREATE OR REPLACE TABLE DWH.CORE.COR_EN_BK_MULTIPART_NOT_NULLABLE (
     BG_SOURCESYSTEM VARCHAR NULL
    ,BG_LOADTIMESTAMP TIMESTAMP_TZ NOT NULL
    ,BG_UPDATETIMESTAMP TIMESTAMP_TZ NOT NULL
    ,BK_MULTIPART_NOT_NULLABLE_SK INTEGER IDENTITY ORDER NOT NULL
    ,BDC_SHOP_ID VARCHAR NOT NULL
    ,BDC_CUSTOMER_ID1 VARCHAR NOT NULL
    ,BG_ROWHASHSCD1 BINARY(32) NOT NULL
    ,CONSTRAINT PK_COR_EN_BK_MULTIPART_NOT_NULLABLE
        PRIMARY KEY (BK_MULTIPART_NOT_NULLABLE_SK)
    ,CONSTRAINT UC_COR_EN_BK_MULTIPART_NOT_NULLABLE
        UNIQUE (BDC_SHOP_ID, BDC_CUSTOMER_ID1)
)
;
INSERT
INTO DWH.CORE.COR_EN_BK_MULTIPART_NOT_NULLABLE (
     BG_SOURCESYSTEM
    ,BG_LOADTIMESTAMP
    ,BG_UPDATETIMESTAMP
    ,BK_MULTIPART_NOT_NULLABLE_SK
    ,BDC_SHOP_ID
    ,BDC_CUSTOMER_ID1
    ,BG_ROWHASHSCD1
)
SELECT
     CAST('Unknown' AS VARCHAR) AS BG_SOURCESYSTEM
    ,CAST('1900-01-01' AS TIMESTAMP_TZ) AS BG_LOADTIMESTAMP
    ,CAST('1900-01-01' AS TIMESTAMP_TZ) AS BG_UPDATETIMESTAMP
    ,CAST(-1 AS INTEGER) AS BK_MULTIPART_NOT_NULLABLE_SK
    ,CAST('Unknown' AS VARCHAR) AS BDC_SHOP_ID
    ,CAST('Unknown' AS VARCHAR) AS BDC_CUSTOMER_ID1
    ,CAST(X'00' AS BINARY(32)) AS BG_ROWHASHSCD1
WHERE NOT EXISTS (
          SELECT
               1
          FROM DWH.CORE.COR_EN_BK_MULTIPART_NOT_NULLABLE
          WHERE BK_MULTIPART_NOT_NULLABLE_SK = CAST(-1 AS INTEGER)
      )
;

The unknown-member row uses the Begin of Universe 1900-01-01 and the text Unknown.

Release differences

Project Settings shows the Generator Version of your project.

  • Generator 2.2: the project properties Persist Validity, Create Result Views, Hash Casing, Hash Concatenation Separator, Hash Null Placeholder, Hash Trim, Apply Sensitivity Level Tags and Sensitivity Level Tag Name; the model object property Increment Management Type on Stage and Fact.
  • Generator 2.3: the model object property Custom Singleton Values on Entity.
  • Generator 2.4: Hash Algorithm defaults to SHA2-256 instead of HASH and also offers MD5; the hash Default Terms are BINARY(32) instead of NUMBER(19), see Generators Release - 2.4.0.
  • Generator 1.10: the project property Delta Detection. Since Generator 2.0, Delta Detection is a property of the Entity.

Related articles