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:
- Table Model: Built on top of a physical database table
- Query Model: Built on top of a custom SQL query
Common parameters
These parameters are shared by both Table Models and Query Models:
| Parameter name | Description |
|---|---|
| type | Model type: 'table' for Table Model, 'query' for Query Model |
| label | User-friendly name for the model, shown to consumers of the dataset |
| description | Description of the model. Support Markdown. |
| data_source_name | The data source on which the SQL generated from this model is executed |
| owner | Define who should be in charge of managing the current model |
| dimension | Define a dimension. See Model Fields |
| measure | Define 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) ;;
}
}