AMQL Docs
AML ReferenceObjectsModel

AML Table Model

Reference for AML Table Model syntax, covering all parameters (type, label, data source, dimensions, measures) and a code example to map a table to a model.

Introduction

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

Parameter definition

Parameter nameDescription
typeModel type: 'table' for Table Model, 'query' for Query Model
labelUser-friendly name for the model, shown to consumers of the dataset
descriptionDescription of the model. Support Markdown.
data_source_nameThe data source on which the SQL generated from this model is executed
ownerDefine who should be in charge of managing the current model
table_namePath to the table underlying this model, in the form: '"schema_name"."table_name"'
dimensionDefine a dimension.
measureDefine a measure.

Code Example

Model users {
  type: 'table'
  label: "Users"
  data_source_name: 'your_datasource_name'
  table_name: 'ecommerce.users' // underlying table of the model

  dimension id {
    label: 'ID'
    type: 'number'
    primary_key: true // recommended for query optimization and AQL features
    hidden: false // optional
    definition: @sql {{#SOURCE.id}};; // optional
  }

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

  measure user_count {
    type: 'number'
    label: 'Count Users'
    definition: @aql count(users.id);;
  }
}

On this page