Skip to content

TODO

Persistent Staging Area Generate Table From User Managed

Section titled “Persistent Staging Area Generate Table From User Managed”

This code-generation template creates table creation scripts for Snowflake based on Persistent Staging Area (PSA) conventions.

PSA tables typically follow the structure of the operational data systems to which the data solution interfaces. The PSA object contains a number of standard columns, which will be added to the definition by this template.

  • Snowflake

This template is intended to assign to ‘source’ objects. It will add the defined data solution standard columns and streamline the data types.

N/A.

N/A.

--
-- Persistent Staging Area table creation statement for {{./conventions.persistentStagingAreaObjectLocation}}.{{./conventions.persistentStagingAreaObjectPrefix}}_{{lookupExtension extensions "originatingSystem"}}_{{name}}.
--
-- Generated from template '{{templateMetadata.name}}'.
--
DROP TABLE IF EXISTS "{{./conventions.persistentStagingAreaObjectLocation}}.{{./conventions.persistentStagingAreaObjectPrefix}}_{{lookupExtension extensions "originatingSystem"}}_{{name}}";
CREATE TABLE "{{./conventions.persistentStagingAreaObjectLocation}}.{{./conventions.persistentStagingAreaObjectPrefix}}_{{lookupExtension extensions "originatingSystem"}}_{{name}}"
(
"{{./conventions.inscriptionTimeStampColumn}}" TIMESTAMP_NTZ NOT NULL
,"{{./conventions.inscriptionRecordIdColumn}}" NUMBER NOT NULL
,"{{./conventions.sourceTimestampColumn}}" TIMESTAMP_NTZ NOT NULL
,"{{./conventions.changeDataColumn}}" VARCHAR NOT NULL
,"{{./conventions.auditTrailIdColumn}}" NUMBER NOT NULL
,"{{./conventions.checksumColumn}}" BINARY(64) NOT NULL
{{#each dataItems}}
,"{{stringupper name}}" {{dataType}}{{#stringcompare dataType "INT"}}{{else}}{{#stringcompare dataType "DATE"}}{{else}}{{#stringcompare dataType "DATETIME"}}{{else}}{{#stringcompare dataType "TIMESTAMP_NTZ"}}{{else}}{{#stringcompare dataType "TIMESTAMP"}}{{else}}{{#stringcompare dataType "DECIMAL"}}{{else}}{{#stringcompare dataType "VARCHAR"}}{{else}}({{characterLength}}{{#stringcompare dataType "NUMBER"}}38,{{/stringcompare}}37){{/stringcompare}}{{/stringcompare}}{{/stringcompare}}{{/stringcompare}}{{/stringcompare}}{{/stringcompare}}{{/stringcompare}} NULL
{{/each}}
);