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

function blocks

function.arg

function.arg attributes
NameRequiredValue
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 constraints

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

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
schematrue

Object reference to schema

materialized constraints

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

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
deterministicfalsebool
langtrue

Procedure language can be one of:

  1. enum (SQL, PYTHON)
schematrue

Object reference to schema

securityfalse

enum (DEFINER, INVOKER)

procedure blocks

procedure.arg

procedure.arg attributes
NameRequiredValue
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 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
locationfalsestring
propertiesfalsemap
providerfalsestring
schematrue

Object reference to schema

table blocks

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
columnsfalse

List of object reference to column

table.column

table.column attributes
NameRequiredValue
commentfalsestring
defaultfalse

Column default expression 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
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
columnsfalse

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 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
schematrue

Object reference to schema

view constraints

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