AML Partial
Introduction
In many situations, you may need to create multiple objects that share certain similarities. For instance, you might want to create two dashboards that have a common set of widgets, as well as some unique widgets for each dashboard. Similarly, you may have two separate datasets that share a few common metrics. The AML Partial feature allows you to extract the shared logic into a new object, making it ready for reuse across multiple objects.
Many Holistics' built-in types support AML Partial: PartialModel
, PartialTableModel
, PartialQueryModel
, PartialDataset
, PartialDashboard
, PartialVizBlock
, PartialPageTheme
and PartialBlockTheme
.
AML Partial is commonly used in conjunction with AML Extend. See syntax and example usages below for more details.
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)