Skip to main content

Redshift Schema

materialized

The materialized block describes a materialized view in a database schema.

materialized "name" {
schema = schema.public
column "total" {
null = true
type = numeric
}
...
}

materialized attributes

NameRequiredValue
astruestring
auto_refreshfalsebool
commentfalsestring
depends_onfalse

List of object references

schematrue

Object reference to schema

materialized blocks

materialized.column

materialized.column attributes
NameRequiredValue
commentfalsestring
nullfalsebool
typetrue

Column type can be one of:

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

materialized.distribution

materialized.distribution attributes
NameRequiredValue
columnfalse

Object reference

stylefalse

enum (EVEN, ALL, KEY)

materialized.sort

materialized.sort attributes
NameRequiredValue
columnsfalse

List of object reference to column

stylefalse

enum (COMPOUND)

materialized constraints

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

schema

The schema block describes a database schema.

schema "public" {
...
}

schema attributes

NameRequiredValue
commentfalsestring
namefalsestring

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
schematrue

Object reference to schema

table blocks

table.column

table.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")
encodefalse

enum (RAW, AZ64, BYTEDICT, DELTA, DELTA32K, LZO, MOSTLY8, MOSTLY16, MOSTLY32, RUNLENGTH, TEXT255, TEXT32K, ZSTD)

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.distribution

table.distribution attributes
NameRequiredValue
columnfalse

Object reference

stylefalse

enum (EVEN, KEY, ALL, AUTO)

table.sort

table.sort attributes
NameRequiredValue
columnsfalse

List of object reference to column

stylefalse

enum (AUTO, COMPOUND, INTERLEAVED)

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
nullfalsebool
typetrue

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