Skip to main content

AML Partial

Introduction

Partial allows you to extract the shared logic into a new object, making it ready for reuse across multiple objects.

Example: Model partial to reuse timestamp dimensions
// Declaring a partial object
PartialModel partial_timestamps {
dimension created_at {
type: 'datetime'
definition: @sql {{ #SOURCE.created_at }};;
}
dimension updated_at {
type: 'datetime'
definition: @sql {{ #SOURCE.updated_at }};;
}
}
Model users = Model {
dimension id { ... }
dimension username { ... }
dimension email { ... }
}.extend(partial_timestamps)

AML Partial is commonly used in conjunction with AML Extend. See syntax and example usages below for more details.

Many Holistics' built-in types support AML Partial: PartialModel, PartialTableModel, PartialQueryModel, PartialDataset, PartialDashboard, PartialVizBlock, PartialPageTheme and PartialBlockTheme.

Syntax

// Declaring a partial object
// type can be any of supported types: Model, TableModel, QueryModel, Dataset,
// Dashboard, VizBlock, PageTheme, BlockTheme
Partial<type> <partialName> {
// properties
}

// Usage (together with extend)
// by extending a declared object
<type> <name> = <type> {
// properties
}.extend(<partialName>)

// Alternatively, by extending partial object itself
<type> <name> = <partialName>.extend({
// properties
})

Example usages

Reusing metrics across multiple datasets:

// Define a Partial Type of Dataset which contains a group of metrics
PartialDataset revenue_metrics {
metric gmv { ... }
metric mrr { ... }
metric arr { ... }
}

// In company.dataset.aml
// Extending original object with the partial object
Dataset company {
// details omitted...
}
Dataset company_with_revenue = company.extend(revenue_metrics)

// In store.dataset.aml
// Alternatively, you can extend the partial object itself
Dataset store_with_revenue = revenue_metrics.extend({
metric store_sales { ... }
})

// In distric.dataset.aml
// You can also extend inline like below
Dataset district_with_revenue = Dataset {
// distric dataset details...
}.extend(revenue_metrics)

Reusing widgets across multiple dashboards:

PartialDashboard common_widgets {
block revenue_chart: VizBlock { ... }
block sales_chart: VizBlock { ... }
}

Dashboard dashboard1 = Dashboard {
widget new_chart { ... }
}.extend(common_widgets)

Dashboard dashboard2 = Dashboard {
widget new_chart { ... }
}.extend(common_widgets)

Let us know what you think about this document :)