AMQL Docs
AML ReferenceObjectsDataset

AML Dataset

Dataset definition syntax in AML: metadata, models, relationships, cross-model fields and the view block.

Introduction

Datasets are defined in .dataset.aml files. The full dataset file name has the form dataset_name.dataset.aml. A dataset definition typically contains:

  • Dataset metadata: label, description, owner
  • The data source its queries run against
  • The models it includes
  • Relationships between those models
  • Cross-model dimensions and metrics
  • An optional view block that organizes models and fields for consumers

The following section lists all dataset parameters.

Parameter definition

Parameter nameDescription
datasetThe dataset's unique name in the project
labelUser-friendly name for the dataset, shown to consumers
descriptionDataset description
ownerWho is in charge of managing the dataset
data_source_nameThe data source that queries against this dataset are executed on
relationshipsRelationships and their configuration among the included models
modelsWhich models are included in the dataset
viewHow models and fields are grouped and ordered for consumers
dimensionCross-model dimensions defined on the dataset
metricMetrics defined on the dataset

Dataset syntax examples

Core: metadata, models, and relationships

Every dataset starts with metadata and declares which models and relationships to include:

Dataset ecommerce {
  label: 'Ecommerce'
  description: 'Demo dataset for E-commerce use cases'
  owner: '[email protected]'
  data_source_name: 'demodb'

  models: [
    ecommerce_orders,
    ecommerce_order_items,
    ecommerce_users,
    ecommerce_products,
    ecommerce_categories
  ]

  relationships: [
    relationship(ecommerce_orders.user_id > ecommerce_users.id, true),
    relationship(ecommerce_order_items.order_id > ecommerce_orders.id, true),
    relationship(ecommerce_order_items.product_id > ecommerce_products.id, true),
    relationship(ecommerce_products.category_id > ecommerce_categories.id, true)
  ]
}

Dimensions and metrics

You can define cross-model dimensions and metrics directly in the dataset using AQL expressions. For full details, see Dataset Fields.

Dataset ecommerce {
  // ... models and relationships omitted

  // Cross-model dimension
  dimension full_name {
    model: ecommerce_users
    type: 'text'
    label: 'Full Name'
    definition: @aql concat(ecommerce_users.first_name, ' ', ecommerce_users.last_name);;
  }

  // Simple aggregation
  metric count_orders {
    label: 'Count Orders'
    type: 'number'
    definition: @aql count(ecommerce_orders.id) ;;
  }

  // Cross-model aggregation
  metric sum_order_value {
    label: 'Sum Order Values'
    type: 'number'
    definition: @aql sum(ecommerce_order_items, ecommerce_order_items.quantity * ecommerce_products.price) ;;
  }

  // Derived metric referencing other metrics
  metric average_order_value {
    label: 'Average Order Value'
    type: 'number'
    definition: @aql sum_order_value / count_orders;;
  }
}

View

Use view to control how models and fields are grouped and ordered when a consumer browses the dataset. Models and metrics listed outside a group appear at the top level; a group collects related ones under a heading.

Dataset ecommerce {
  // ... models, relationships, dimensions, metrics omitted

  view {
    model ecommerce_orders { }
    model ecommerce_users { }

    group relevant_models {
      model ecommerce_products { }
      model ecommerce_categories { }
    }

    group business_metrics {
      metric sum_order_value
      metric average_order_value
    }
  }
}

On this page