Skip to main content

Databricks Schema

function​

The function block describes a function in a database schema.

function "positive" {
schema = schema.public
lang = SQL
arg "v" {
type = integer
}
...
}

function attributes​

NameRequiredValue
astruestring
commentfalsestring
deterministicfalsebool
langtrue

Function language can be one of:

  1. enum (SQL, PYTHON)
returnfalse

Function return type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
schematrue

Object reference to schema

sql_data_accessfalse

enum (CONTAINS_SQL, READS_SQL_DATA)

function blocks​

function.annotation​

function.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

function.arg​

function.arg attributes​
NameRequiredValue
commentfalsestring
defaultfalse

Argument default value can be one of:

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

Argument type can be one of:

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

function.return_table​

function.return_table blocks​

function.return_table.column​

function.return_table.column attributes​
NameRequiredValue
typetrue

Function return_table column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
function.return_table.column blocks​

function.return_table.column.annotation​

function.return_table.column.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue
function.return_table.column constraints​
ConstraintValue
Requiredtrue
Require Name (e.g., function.return_table.column "name" )true
Repeatabletrue

function constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., function "name" )true
Allow Qualifier (e.g., function "schema" "name" )true
Repeatabletrue
Mutually exclusive sets[return, return_table]

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
collationfalsestring
commentfalsestring
depends_onfalse

List of object references

propertiesfalsemap
providerfalsestring
schematrue

Object reference to schema

tagsfalsemap

materialized blocks​

materialized.annotation​

materialized.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

materialized.cluster​

materialized.cluster attributes​
NameRequiredValue
autofalsebool
columnsfalse

List of object reference to column

materialized.cluster constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[columns, auto]
One of required sets[columns, auto]

materialized.column​

materialized.column attributes​
NameRequiredValue
commentfalsestring
nullfalsebool
tagsfalsemap
typetrue

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
materialized.column blocks​

materialized.column.annotation​

materialized.column.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

materialized.column.mask​

materialized.column.mask attributes​
NameRequiredValue
functiontrue

Object reference to function

using_columnsfalse

List of object reference to column

materialized.column constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., materialized.column "name" )true

materialized.expect​

materialized.expect attributes​
NameRequiredValue
exprtruestring
on_violationfalse

enum (FAIL_UPDATE, DROP_ROW)

materialized.expect constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., materialized.expect "name" )true
Repeatabletrue

materialized.foreign_key​

materialized.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
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
materialized.foreign_key constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., materialized.foreign_key "name" )true

materialized.partition​

materialized.partition attributes​
NameRequiredValue
columnstrue

List of object reference to column

materialized.primary_key​

materialized.primary_key attributes​
NameRequiredValue
columnstrue

Primary key columns can be one of:

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

materialized.refresh​

materialized.refresh attributes​
NameRequiredValue
at_mostfalsestring
cronfalsestring
everyfalsestring
on_updatefalsebool
time_zonefalsestring
materialized.refresh constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[every, cron], [every, on_update], [cron, on_update]
One of required sets[every, cron, on_update]

materialized.row_filter​

materialized.row_filter attributes​
NameRequiredValue
columnsfalse

List of object reference to column

functiontrue

Object reference to function

materialized constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., materialized "name" )true
Allow Qualifier (e.g., materialized "schema" "name" )true
Mutually exclusive sets[partition, cluster]

permission​

The permission block describes permissions (privileges) granted on database objects.

permission {
to = "user1"
for = table.users
privileges = [SELECT, MODIFY]
}
permission {
to = "admin"
for = schema.default
privileges = [MANAGE]
}

permission attributes​

NameRequiredValue
fortrue

Permission target resource can be one of:

  1. Object reference to schema
  2. Object reference to table
  3. Object reference to view
  4. Object reference to materialized
  5. Object reference to streaming_table
  6. Object reference to function
  7. Object reference to procedure
privilegestrue

List of strings

totruestring

permission constraints​

ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

procedure​

The procedure block describes a procedure in a database schema.

procedure "proc" {
schema = schema.public
lang = SQL
arg "a" {
type = integer
}
...
}

procedure attributes​

NameRequiredValue
astruestring
commentfalsestring
deterministicfalsebool
langtrue

Procedure language can be one of:

  1. enum (SQL, PYTHON)
schematrue

Object reference to schema

securityfalse

enum (DEFINER, INVOKER)

sql_data_accessfalse

enum (MODIFIES_SQL_DATA)

procedure blocks​

procedure.annotation​

procedure.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

procedure.arg​

procedure.arg attributes​
NameRequiredValue
commentfalsestring
defaultfalse

Argument default value can be one of:

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

enum (IN, OUT, INOUT)

typetrue

Argument type can be one of:

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

procedure constraints​

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

schema​

The schema block describes a database schema.

schema "public" {
...
}

schema attributes​

NameRequiredValue
collationfalsestring
commentfalsestring
tagsfalsemap

schema blocks​

schema.annotation​

schema.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

schema constraints​

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

streaming_table​

The streaming_table block describes a streaming table: a table a streaming query fills, refreshed by a pipeline Databricks provisions for it.

streaming_table "orders" {
schema = schema.default
column "id" {
null = false
type = BIGINT
}
expect "valid_id" {
expr = "id > 0"
on_violation = DROP_ROW
}
refresh {
every = "1 HOUR"
}
as = "SELECT id FROM STREAM(raw_orders)"
}

streaming_table attributes​

NameRequiredValue
astruestring
commentfalsestring
depends_onfalse

List of object references

propertiesfalsemap
schematrue

Object reference to schema

tagsfalsemap

streaming_table blocks​

streaming_table.cluster​

streaming_table.cluster attributes​
NameRequiredValue
autofalsebool
columnsfalse

List of object reference to column

streaming_table.cluster constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[columns, auto]
One of required sets[columns, auto]

streaming_table.column​

streaming_table.column attributes​
NameRequiredValue
collationfalsestring
commentfalsestring
defaultfalse

Column default expression can be one of:

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

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
streaming_table.column blocks​

streaming_table.column.annotation​

streaming_table.column.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

streaming_table.column.identity​

streaming_table.column.identity attributes​
NameRequiredValue
by_defaultfalsebool
incrementfalseint
startfalseint

streaming_table.column.mask​

streaming_table.column.mask attributes​
NameRequiredValue
functiontrue

Object reference to function

using_columnsfalse

List of object reference to column

streaming_table.column constraints​
ConstraintValue
Requiredtrue
Require Name (e.g., streaming_table.column "name" )true
Mutually exclusive sets[default, identity]

streaming_table.expect​

streaming_table.expect attributes​
NameRequiredValue
exprtruestring
on_violationfalse

enum (FAIL_UPDATE, DROP_ROW)

streaming_table.expect constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., streaming_table.expect "name" )true
Repeatabletrue

streaming_table.foreign_key​

streaming_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
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
streaming_table.foreign_key constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., streaming_table.foreign_key "name" )true

streaming_table.partition​

streaming_table.partition attributes​
NameRequiredValue
columnstrue

List of object reference to column

streaming_table.primary_key​

streaming_table.primary_key attributes​
NameRequiredValue
columnstrue

Primary key columns can be one of:

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

streaming_table.refresh​

streaming_table.refresh attributes​
NameRequiredValue
at_mostfalsestring
cronfalsestring
everyfalsestring
on_updatefalsebool
time_zonefalsestring
streaming_table.refresh constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[every, cron], [every, on_update], [cron, on_update]
One of required sets[every, cron, on_update]

streaming_table.row_filter​

streaming_table.row_filter attributes​
NameRequiredValue
columnsfalse

List of object reference to column

functiontrue

Object reference to function

streaming_table constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., streaming_table "name" )true
Allow Qualifier (e.g., streaming_table "schema" "name" )true
Mutually exclusive sets[partition, cluster]

table​

The table block describes a table in a database schema.

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

table attributes​

NameRequiredValue
collationfalsestring
commentfalsestring
depends_onfalse

List of object references

locationfalsestring
propertiesfalsemap
providerfalsestring
schematrue

Object reference to schema

tagsfalsemap

table blocks​

table.annotation​

table.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

table.check​

table.check attributes​
NameRequiredValue
exprtruestring
table.check constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., table.check "name" )true
Repeatabletrue

table.cluster​

table.cluster attributes​
NameRequiredValue
autofalsebool
columnsfalse

List of object reference to column

table.cluster constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[columns, auto]
One of required sets[columns, auto]

table.column​

table.column attributes​
NameRequiredValue
asfalsestring
collationfalsestring
commentfalsestring
defaultfalse

Column default expression can be one of:

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

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
table.column blocks​

table.column.annotation​

table.column.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

table.column.identity​

table.column.identity attributes​
NameRequiredValue
by_defaultfalsebool
incrementfalseint
startfalseint

table.column.mask​

table.column.mask attributes​
NameRequiredValue
functiontrue

Object reference to function

using_columnsfalse

List of object reference to column

table.column constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., table.column "name" )true
Mutually exclusive sets[default, as, identity]

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
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.partition​

table.partition attributes​
NameRequiredValue
columnstrue

List of object reference to column

table.primary_key​

table.primary_key attributes​
NameRequiredValue
columnstrue

Primary key columns can be one of:

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

table.row_filter​

table.row_filter attributes​
NameRequiredValue
columnsfalse

List of object reference to column

functiontrue

Object reference to function

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
collationfalsestring
commentfalsestring
depends_onfalse

List of object references

metricsfalsebool
propertiesfalsemap
schematrue

Object reference to schema

schema_bindingfalse

enum (BINDING, COMPENSATION, TYPE_EVOLUTION, EVOLUTION)

tagsfalsemap

view blocks​

view.annotation​

view.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

view.column​

view.column attributes​
NameRequiredValue
commentfalsestring
nullfalsebool
tagsfalsemap
typetrue

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
view.column blocks​

view.column.annotation​

view.column.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue
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