Skip to main content

Table Model (AML)

Intro

Table Model defines a data model that sits on top of a database table.

Syntax Construct

Model model_name {
type: 'table'
label: "Model Label"
description: ""
owner: '[email protected]'
data_source_name: 'data_source_name'

table_name: '"schema"."table_name"'

dimension dimension_name_1 {
// dimension 1 definition
label: 'Dimension Label 1'
type: 'text | number | date | datetime | truefalse'
description: 'Field Description'
hidden: true|false
definition: @sql {{#SOURCE.column_name}};;
}

dimension dimension_name_2 {
// dimension 2 definition
}

measure measure_name_1 {
// measure 1 definition
label: 'Measure Name 1'
type: 'number | date | datetime'
definition: @sql {{#SOURCE.column_name}};;
aggregation_type: 'count | count_distinct | sum | avg'
}

}

Example Code

Model users {
type: 'table'
label: "Users"
data_source_name: 'bigquery_dw'
table_name: 'users'

dimension id {
label: 'ID'
type: 'number'
hidden: false // optional
definition: @sql {{#SOURCE.id}};; // optional
}

dimension email {
label: 'Email'
type: 'number'
// without "definition", it automatically uses the same column name as the dimension name ('email')
}

measure user_count {
type: 'number'
label: 'Count Users'
definition: @sql count({{#SOURCE.id}});;
}
}