Skip to main content

Snowflake Schema

dynamic_table

The dynamic block describes a dynamic table in a database schema.

dynamic_table "users" {
schema = schema.public
column "id" {
comment = "User ID"
}
target_lag = DOWNSTREAM // or "<num> { seconds | minutes | hours | days }"
refresh_mode = INCREMENTAL, or FULL
as = "SELECT * FROM users"
...
}

dynamic_table attributes

NameRequiredValue
astruestring
commentfalsestring
depends_onfalse

List of object references

refresh_modefalse

Dynamic table refresh mode can be one of:

  1. string
  2. enum (INCREMENTAL, FULL)
retention_timefalseint
schematrue

Object reference to schema

target_lagtrue

Dynamic table target lag can be one of:

  1. string
  2. enum (DOWNSTREAM)
transientfalsebool

dynamic_table blocks

dynamic_table.column

dynamic_table.column attributes
NameRequiredValue
commentfalsestring
typefalse

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
dynamic_table.column constraints
ConstraintValue
Requiredfalse
Require Name (e.g., dynamic_table.column "name" )true

dynamic_table constraints

ConstraintValue
Requiredfalse
Require Name (e.g., dynamic_table "name" )true
Allow Qualifier (e.g., dynamic_table "schema" "name" )true

hybrid_table

The hybrid block describes a hybrid table in a database schema.

hybrid_table "users" {
schema = schema.public
column "id" {
comment = "User ID"
type = VARCHAR(255)
}
primary_key {
columns = ["id"]
}
...
}

hybrid_table attributes

NameRequiredValue
commentfalsestring
retention_timefalseint
schematrue

Object reference to schema

hybrid_table blocks

hybrid_table.column

hybrid_table.column attributes
NameRequiredValue
collatefalsestring
commentfalsestring
defaultfalse

Column default value can be one of:

  1. bool
  2. string
  3. number
  4. Raw expression defined with sql("expr")
nullfalsebool
typetrue

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
hybrid_table.column constraints
ConstraintValue
Requiredfalse
Require Name (e.g., hybrid_table.column "name" )true

hybrid_table.foreign_key

hybrid_table.foreign_key attributes
NameRequiredValue
columnstrue

Foreign key columns can be one of:

  1. List of object reference to column
  2. List of object reference to hybrid_table.column
commentfalsestring
ref_columnstrue

Foreign key reference columns can be one of:

  1. List of object reference to column
  2. List of object reference to hybrid_table.column
hybrid_table.foreign_key constraints
ConstraintValue
Requiredfalse
Require Name (e.g., hybrid_table.foreign_key "name" )true

hybrid_table.primary_key

hybrid_table.primary_key attributes
NameRequiredValue
columnstrue

Index columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
commentfalsestring

hybrid_table.unique

hybrid_table.unique attributes
NameRequiredValue
columnstrue

Index columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
commentfalsestring
hybrid_table.unique constraints
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[columns, on]
One of required sets[columns, on]

hybrid_table constraints

ConstraintValue
Requiredfalse
Require Name (e.g., hybrid_table "name" )true
Allow Qualifier (e.g., hybrid_table "schema" "name" )true

schema

The schema block describes a database schema.

schema "public" {
...
}

schema attributes

NameRequiredValue
commentfalsestring
managed_accessfalsebool
namefalsestring
retention_timefalseint
transientfalsebool

schema constraints

ConstraintValue
Requiredfalse
Require Name (e.g., schema "name" )true

table

The table block describes a table in a database schema.

table "users" {
schema = schema.public
column "id" {
type = int
}
...
}

table attributes

NameRequiredValue
commentfalsestring
retention_timefalseint
schematrue

Object reference to schema

transientfalsebool

table blocks

table.column

table.column attributes
NameRequiredValue
collatefalsestring
commentfalsestring
defaultfalse

Column default value can be one of:

  1. bool
  2. string
  3. number
  4. Raw expression defined with sql("expr")
nullfalsebool
typetrue

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
table.column constraints
ConstraintValue
Requiredfalse
Require Name (e.g., table.column "name" )true

table.foreign_key

table.foreign_key attributes
NameRequiredValue
columnstrue

Foreign key columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
commentfalsestring
ref_columnstrue

Foreign key reference columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
table.foreign_key constraints
ConstraintValue
Requiredfalse
Require Name (e.g., table.foreign_key "name" )true

table.primary_key

table.primary_key attributes
NameRequiredValue
columnstrue

Index columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
commentfalsestring

table.unique

table.unique attributes
NameRequiredValue
columnstrue

Index columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
commentfalsestring
table.unique constraints
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[columns, on]
One of required sets[columns, on]

table constraints

ConstraintValue
Requiredfalse
Require Name (e.g., table "name" )true
Allow Qualifier (e.g., table "schema" "name" )true

view

The view block describes a view in a database schema.

view "clean_users" {
schema = schema.public
column "id" {
type = int
}
...
}

view attributes

NameRequiredValue
astruestring
commentfalsestring
depends_onfalse

List of object references

schematrue

Object reference to schema

view blocks

view.column

view.column attributes
NameRequiredValue
commentfalsestring
defaultfalse

Column default value can be one of:

  1. bool
  2. string
  3. number
  4. Raw expression defined with sql("expr")
nullfalsebool
typefalse

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
view.column constraints
ConstraintValue
Requiredfalse
Require Name (e.g., view.column "name" )true

view constraints

ConstraintValue
Requiredfalse
Require Name (e.g., view "name" )true
Allow Qualifier (e.g., view "schema" "name" )true