AMQL Docs
AML ReferenceObjectsModel

AML Model

The AML Model block maps a database table or SQL query to dimensions and measures, giving the semantic layer the structure it needs to explore and aggregate your data.

Introduction

A Model in AML represents either a database table or a SQL query, and contains dimensions and measures that define how data can be explored and aggregated. Models are declared in .model.aml files (one model per file).

Model types

AML supports two types of models:

Common parameters

These parameters are shared by both Table Models and Query Models:

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
dimensionDefine a dimension. See Model Fields
measureDefine a measure. See Model Fields

Basic syntax

Model model_name {
  type: 'table'  // or 'query'
  label: "Model Label"
  description: "Model description here"
  data_source_name: 'your_datasource_name'
  owner: '[email protected]'

  dimension dimension_name {
    label: 'Dimension Label'
    type: 'text'
    definition: @sql {{ #SOURCE.column_name }};;
  }

  measure measure_name {
    label: 'Measure Label'
    type: 'number'
    definition: @aql count(model_name.dimension_name) ;;
  }
}

See also

On this page