DMDL Reference
DAR document
A DAR (Data according to Requirements) document is a YAML file that declares reporting outputs, such as dimensions and facts, on the DAB (Data according to Business), the business model with history. In a Daana project, DAR documents live in dar/, and daana dar check, daana dar lint, daana dar apply and daana dar generate read them.
This page follows the three DAR documents of the bookstore example, which chapter 7 builds step by step. It explains the keys of those documents that the documentation covers so far, and it says where it does not explain a key yet. The field tables are under Quick reference. The fields and output kinds that the bookstore documents do not use are listed under In the specification, not explained yet.
Document structure
The specification defines nine top-level blocks and requires three of them: spec, anchor and outputs, with at least one entry under outputs. The list gives the required blocks first, then the two optional blocks that the bookstore documents use:
spec: Required. The DAR specification version.anchor: Required. What the document declares its outputs on; in the bookstore documents, an entity.outputs: Required. The reporting outputs.source: The DAB entity the document reads.relationships: The entities that the document relates to its anchor entity.
The other four blocks are scopes, stream, provides and lifecycle. This page does not explain them yet.
The customer document is the shortest of the three bookstore documents. It has the three required blocks and source, with one output:
# DAR for the customer: a dimension with history. Every change of name,
# status, city or loyalty tier is a version with valid_from and valid_to.
spec: dar/v1.0
anchor:
entity: customer
source:
dab: customer
outputs:
dim: # compiles to dim__customer (+ __latest)
kind: dimension
description: The customer, with status, city and loyalty tier over time
latest: view
attributes: all
spec, anchor, source
All three bookstore documents start with spec, anchor and source. source is optional in the specification.
Field table: Document fields.
spec
spec names the version of the DAR specification. Its only allowed value is dar/v1.0, as in the customer document:
spec: dar/v1.0
anchor
anchor takes exactly one key. The bookstore documents use entity, which names an entity of the DAB model. The customer document is anchored on customer:
anchor:
entity: customer
During daana dar apply, Daana records what it applied as the active DAR revision in its ledger, with one complete revision for each anchor. A change such as adding a measure gives the document's anchor a new revision, while editing only a description gives none. Changing the changes of a relationship that another document reads through via also gives that document's anchor a new revision. Apply the whole dar/ directory after such a change, because Daana refuses to apply only the changed document and names the document that reads through it.
source
The dab key under source names the DAB entity whose attributes, types and definitions the document reads. The customer document reads customer:
source:
dab: customer
In the three bookstore documents, dab under source and entity under anchor name the same entity. This page does not explain yet how the two differ. daana dar check refuses a source.dab that names no entity of the model, with the error DAR014.
Field table: source fields.
relationships
relationships has one entry for each entity that the document relates to its anchor entity. The specification does not require the block, and the customer document has none. The order document relates order to customer:
relationships:
customer: {changes: never} # an order keeps the customer who placed it
Daana finds the relationship between the anchor and the related entity in the DAB model. Here the anchor is order, and the related entity is customer. daana dar check refuses a relationship whose entity is not in the model (DAR012) or, unless it is reached through via, is not related to the anchor in the model (DAR016).
Field table: relationships fields.
changes
changes takes never or tracked. An entry has either changes or via, not both.
changes: never states that the relationship never changes. In the order document, an order keeps the customer who placed it.
The bookstore documents do not use changes: tracked. The documentation describes it for one case so far: a relationship that Daana walks backwards, from the model relationship's target to its source. How DAR resolves a relationship says what a tracked relationship follows in that case, and Relationship Cardinality says which model declarations allow a backward walk. This page does not explain changes: tracked beyond that yet.
via
via reaches an entity through another relationship in the same document. The order line document reaches customer through order:
relationships:
order: {changes: never} # a line stays on the order it was placed on
customer: {via: order} # the customer who placed that order (dar/order.yaml)
The order entry belongs to this document; dar/order.yaml relates that order to its customer. daana dar check refuses a via that names no relationship of the same document, with the error DAR003.
In dar/order.yaml, changing customer from {changes: never} to {changes: tracked} gives order and order_line new revisions, because dar/order_line.yaml reads that relationship through via. Daana refuses daana dar apply dar/order.yaml alone before changing anything and names order_line.yaml; daana dar apply dar/ applies both.
outputs
Each entry under outputs declares a reporting output under a name chosen by the author. The order line document declares three outputs, one of each kind that this page explains:
outputs:
dim: # compiles to dim__order_line (+ __latest)
kind: dimension
# ...
line_fact: # compiles to fct__order_line
kind: fact.state
# ...
daily_revenue: # compiles to fct__order_line_daily_revenue
kind: fact.consolidated
The table says what one row is for each kind that this page explains. Its last row lists the other kinds of the specification, which this page does not explain yet.
| Kind | One row is |
|---|---|
dimension | One version of the entity |
fact.state | One entity at its axis timestamp |
fact.consolidated | One combination of the grain columns |
fact.event, fact.projection, fact.periodic_snapshot, fact.lifecycle, fact.union, fact.unified_star, bridge, entity_assembly, reference.computed, reference.static, reference.external, serve.view, serve.table | In the specification, not explained yet |
The following table lists the objects in the daana_dar schema after daana dar apply on the three chapter 7 documents, as recorded. The comment beside each output in the documents names the object it compiles to:
| table_name | table_type |
|---|---|
| dim__customer | VIEW |
| dim__customer__latest | VIEW |
| dim__order | VIEW |
| dim__order__latest | VIEW |
| dim__order_line | VIEW |
| dim__order_line__latest | VIEW |
| fct__order_line | VIEW |
| fct__order_line__wide | VIEW |
| fct__order_line_daily_revenue | VIEW |
| intm__rel_order | VIEW |
| intm__rel_order_line | VIEW |
All eleven objects are views. intm__rel_order and intm__rel_order_line are not declared as outputs: they hold the relationship histories that keys uses. The names are those of this recorded apply; this page does not state a naming rule yet.
Field tables: kind: dimension fields, kind: fact.state fields, kind: fact.consolidated fields.
kind: dimension
A dimension has one row for each version of the entity, with valid_from and valid_to marking the interval when that version is valid. The customer document creates dim__customer, a type 2 dimension:
outputs:
dim: # compiles to dim__customer (+ __latest)
kind: dimension
description: The customer, with status, city and loyalty tier over time
latest: view
attributes: all
Revenue by loyalty tier when each line was received shows how these validity intervals support reporting at a past instant. For description, see description.
Field table: kind: dimension fields.
latest
latest: view adds a view with each entity's current version. In the customer document, this entry adds dim__customer__latest:
latest: view
The specification also allows latest: none and latest: table. This page does not explain them yet.
attributes
attributes: all includes all attributes of the entity in the dimension. The customer dimension uses this value:
attributes: all
The specification also allows a list of attribute names, which this page does not explain yet. daana dar check refuses a name in the list that is not an attribute of the entity named by source.dab, with the error DAR015.
kind: fact.state
A state fact has one row for each entity at its axis timestamp, the timestamp that dates the row. In the chapter 7 documents, the axis is the order line's load time. Chapter 8 changes the axis to the order's time, in a declaration without keys or wide. With either axis, keys gives the chapter 7 line fact both keys, and wide reads the customer version valid at the axis timestamp.
The order line document declares line_fact, whose axis is the order line's effective timestamp:
line_fact: # compiles to fct__order_line
kind: fact.state
description: >
One row per order line, at the time it was received in stage. Lines that
were received today appear once the day is over.
axis:
expr: eff_tmstp # ingested_at: when the line was received in stage
description: When the line was received in stage, a load time; on the order's day while lines arrive on time
measures:
- name: order_line_amount_amount
additivity: additive
description: Amount charged for the line, tax included
columns: [order_line_amount_currency]
keys: [order, customer] # the line's order and that order's customer
wide: # compiles to fct__order_line__wide
dims:
customer: [customer_name, customer_loyalty_tier] # from dim__customer, as of fact_ts
Declare daily revenue introduces this fact and the daily revenue output that reads it. The subsections below follow the keys of this declaration; description and checks are under Fields of several kinds.
Field table: kind: fact.state fields.
axis
The expr key under axis is the expression that dates each row of the fact. In the line fact it is eff_tmstp, and the fact shows its value in the column fact_ts:
axis:
expr: eff_tmstp # ingested_at: when the line was received in stage
description: When the line was received in stage, a load time; on the order's day while lines arrive on time
Here eff_tmstp is the order line's effective timestamp, which the mapping sets to its load time: the time at which the line arrived in the source table.
Field table: axis fields.
measures and columns
The line fact lists order_line_amount_amount under measures and order_line_amount_currency under columns:
measures:
- name: order_line_amount_amount
additivity: additive
description: Amount charged for the line, tax included
columns: [order_line_amount_currency]
Both are columns of fct__order_line: chapter 7's query on the line fact selects them. This page does not explain yet how a measure differs from a column, or what a measure's additivity does.
Field table: measures fields.
keys
keys adds a key column for each named relationship. The line's order relationship declares changes: never, as does the customer relationship in the order document. Daana therefore reads each key from the latest link, whatever fact_ts is. This list adds order_key and customer_key to fct__order_line:
keys: [order, customer] # the line's order and that order's customer
wide
The dims key under wide lists attributes to join from the dimension version valid at fact_ts. The line fact takes two attributes of the customer:
wide: # compiles to fct__order_line__wide
dims:
customer: [customer_name, customer_loyalty_tier] # from dim__customer, as of fact_ts
Daana creates fct__order_line__wide, which joins each line to the version of dim__customer valid at fact_ts. The view adds the listed attributes, customer_name and customer_loyalty_tier.
The axis can also be the order's time, as in chapter 8's fix. On this line fact, the wide view then reads the customer version valid at the order's time.
Field table: wide fields.
kind: fact.consolidated
A consolidated fact has one row for each combination of its grain columns. In the bookstore, daily_revenue sums the line fact's amounts by day and currency. It has one entry under legs, named lines, and this page does not show how several entries are combined. The order line document declares daily_revenue:
daily_revenue: # compiles to fct__order_line_daily_revenue
kind: fact.consolidated
description: >
Daily revenue: order lines' amounts summed by the day the line was received,
its order's day while lines arrive on time. One row per day and currency;
every line is USD in this data.
grain: [received_date, order_line_amount_currency]
spine: {driving: lines}
legs:
lines:
fact: order_line.line_fact
date: "CAST(fact_ts AS DATE)" # the day the line was received: its order's day while lines arrive on time
order_line_amount_currency: order_line_amount_currency
aggregates:
daily_revenue_amount:
expr: order_line_amount_amount
agg: sum
description: >
Daily revenue: the amounts charged on the order lines that
were received that day, tax included, in the lines' currency.
ai_context:
synonyms: [daily revenue, revenue per day, daily sales, sales by day]
Query the daily revenue shows the resulting amounts by day and currency. description and materialize are under Fields of several kinds, and this page does not explain spine yet.
Field tables: kind: fact.consolidated fields, spine fields.
grain
grain lists the columns that define one row of the consolidated fact. The daily revenue grain gives one row for each date and currency:
grain: [received_date, order_line_amount_currency]
legs
The daily revenue declaration has one entry under legs, named lines:
legs:
lines:
fact: order_line.line_fact
date: "CAST(fact_ts AS DATE)" # the day the line was received: its order's day while lines arrive on time
order_line_amount_currency: order_line_amount_currency
For the same entry, Generate DAR for Dataform shows the query that Daana generates: it sums order_line_amount_amount from fct__order_line by CAST(fact_ts AS DATE) and currency. This page does not explain the keys of a legs entry yet: fact, date and the entry for a grain column.
Field table: legs fields.
aggregates
An aggregate's expr names what to aggregate, here a column, and agg names the function. daily_revenue_amount sums order_line_amount_amount:
aggregates:
daily_revenue_amount:
expr: order_line_amount_amount
agg: sum
description: >
Daily revenue: the amounts charged on the order lines that
were received that day, tax included, in the lines' currency.
ai_context:
synonyms: [daily revenue, revenue per day, daily sales, sales by day]
This page does not explain ai_context yet. For the aggregate's description, see description.
Field tables: aggregates fields, ai_context fields.
Fields of several kinds
description, checks and materialize are fields shared by several output kinds. Each subsection lists the kinds that accept the field, as given by the specification.
description
The bookstore documents give a description to every output, and also to the axis, the measure, the check and the aggregate. daana dar lint checks the documents' descriptions and style. This page does not explain yet where Daana shows a description.
Kinds: dimension, fact.event, fact.state, fact.projection, fact.periodic_snapshot, fact.lifecycle, fact.consolidated, fact.union, fact.unified_star, bridge, entity_assembly, reference.computed, reference.static, reference.external, serve.view, serve.table
checks
A check's expr is a SQL condition over one output that passes only when its result is TRUE; NULL fails. Daana runs output checks after creating the outputs during daana dar apply. The line fact's check tests for missing amounts:
checks:
every_line_has_an_amount:
# A NULL discount makes line_total NULL; SUM would skip the line.
expr: COALESCE(SUM(IF(order_line_amount_amount IS NULL, 1, 0)), 0) = 0
over: output
severity: error
description: Every order line carries the amount charged.
The check counts lines without an amount and passes when there are none. An aggregate over an empty output is NULL, and NULL fails; the COALESCE turns it into 0, so an empty output passes and the check does not test that the output has rows.
over: outputruns the condition over the output. Every check in the documentation uses this value.severity: errorfails the apply with exit status 1. Daana has already replaced the outputs at that point, and the ledger keeps the previously active revision.severity: warnprints a warning and lets the apply continue.description: see description.
A document without checks applies with no output checks: chapter 7's first apply reports after 0 checks.
Output checks run on DuckDB. For any other target, daana dar apply refuses a document that has an output check, and daana dar generate refuses it too, so a document with checks cannot be generated for Dataform. See Output checks for examples and What a check does not do for why a later daana execute does not run them.
Kinds: dimension, fact.event, fact.state, fact.projection, fact.periodic_snapshot, fact.lifecycle, fact.consolidated, fact.union, fact.unified_star, entity_assembly, reference.computed
Field table: checks fields.
materialize
materialize: table creates an output as a table instead of a view. The chapter 7 documents have no materialize, and all their outputs are views.
A table holds what the last daana dar apply wrote; daana execute does not refresh it. Set materialize: table before the output's first apply: daana dar apply refuses, before it writes anything, to change a published view to a table or a table to a view in place. On PostgreSQL, a view that reads a DAR table and that the apply does not create stops the table's rebuild; the apply guide explains both refusals.
Kinds: fact.event, fact.state, fact.projection, fact.periodic_snapshot, fact.lifecycle, fact.consolidated, fact.union, fact.unified_star, bridge, entity_assembly, reference.computed
Complete example
The complete example combines the customer, order and order line documents from chapter 7. Together they declare the dimensions, the line fact with its customer attributes, and daily revenue.
dar/customer.yaml declares the customer dimension:
# DAR for the customer: a dimension with history. Every change of name,
# status, city or loyalty tier is a version with valid_from and valid_to.
spec: dar/v1.0
anchor:
entity: customer
source:
dab: customer
outputs:
dim: # compiles to dim__customer (+ __latest)
kind: dimension
description: The customer, with status, city and loyalty tier over time
latest: view
attributes: all
dar/order.yaml declares the order dimension and relates the order to its customer:
# DAR for the order: the dimension that carries the order's customer, so an
# order line reaches its customer through the order (dar/order_line.yaml).
spec: dar/v1.0
anchor:
entity: order
source:
dab: order
relationships:
customer: {changes: never} # an order keeps the customer who placed it
outputs:
dim: # compiles to dim__order (+ __latest)
kind: dimension
description: The order, with its status, size and value over time
latest: view
attributes: all
dar/order_line.yaml, shown from its spec line, declares the order line dimension, the line fact and daily revenue:
spec: dar/v1.0
anchor:
entity: order_line
source:
dab: order_line # reads model.yaml: attributes, types, definitions
relationships:
order: {changes: never} # a line stays on the order it was placed on
customer: {via: order} # the customer who placed that order (dar/order.yaml)
outputs:
dim: # compiles to dim__order_line (+ __latest)
kind: dimension
description: The order line, with its fulfillment status and amounts over time
latest: view
attributes: all # descriptions from model.yaml
line_fact: # compiles to fct__order_line
kind: fact.state
description: >
One row per order line, at the time it was received in stage. Lines that
were received today appear once the day is over.
axis:
expr: eff_tmstp # ingested_at: when the line was received in stage
description: When the line was received in stage, a load time; on the order's day while lines arrive on time
measures:
- name: order_line_amount_amount
additivity: additive
description: Amount charged for the line, tax included
columns: [order_line_amount_currency]
keys: [order, customer] # the line's order and that order's customer
wide: # compiles to fct__order_line__wide
dims:
customer: [customer_name, customer_loyalty_tier] # from dim__customer, as of fact_ts
checks:
every_line_has_an_amount:
# A NULL discount makes line_total NULL; SUM would skip the line.
expr: COALESCE(SUM(IF(order_line_amount_amount IS NULL, 1, 0)), 0) = 0
over: output
severity: error
description: Every order line carries the amount charged.
daily_revenue: # compiles to fct__order_line_daily_revenue
kind: fact.consolidated
description: >
Daily revenue: order lines' amounts summed by the day the line was received,
its order's day while lines arrive on time. One row per day and currency;
every line is USD in this data.
grain: [received_date, order_line_amount_currency]
spine: {driving: lines}
legs:
lines:
fact: order_line.line_fact
date: "CAST(fact_ts AS DATE)" # the day the line was received: its order's day while lines arrive on time
order_line_amount_currency: order_line_amount_currency
aggregates:
daily_revenue_amount:
expr: order_line_amount_amount
agg: sum
description: >
Daily revenue: the amounts charged on the order lines that
were received that day, tax included, in the lines' currency.
ai_context:
synonyms: [daily revenue, revenue per day, daily sales, sales by day]
The recorded run starts from the chapter 7 project after daana install, daana deploy and daana execute. The dar/ argument selects its DAR documents, and the apply uses the duckdb profile named in daana.yaml. Quit an open DuckDB session with .quit before applying, because the session locks the database file. From the project directory, check the documents and create their outputs:
Run in terminal
daana dar check dar/
daana dar apply dar/
Read the document and output counts in the validation result:
Expected output of daana dar check
Checking dar check: dar/
Spec: dar/v1.0
Anchor: entity:customer
Documents: 3
Outputs: 5
✓ Validation passed
The check reports three documents and five outputs, and validation passes. The Anchor: line names the anchor of one document, customer, although the check covers all three.
daana dar check validates the documents against the DAR specification, then checks rules across the documents in the directory. It also compares each document with the local model: the entity that source.dab names, each relationship, and each name in a dimension's attributes list. It compares the anchor only when source.dab names no entity. The check also compares the names in a fact's measures and columns, an axis that is a plain column, and wide picks (DAR015). An axis expression and an aggregate's expression are not tested. A passing check does not prove that a relationship can be walked or that the amounts in the data are correct.
Read the object and check counts from the apply:
Expected output of daana dar apply
Applied 11 objects (11 views) after 1 checks to daana_dar
Daana created 11 views in daana_dar and ran one output check, which passed. These are the 11 objects listed under outputs.
Quick reference
The tables list the fields, types, required entries and allowed values for the blocks discussed on this page. Kinds that share a definition share a table, and its kind row lists them.
In a field name, <name> stands for a key the author names, and [] stands for each item of a list. In a type, name → T is a map: each key is a name, and each value has the type T. The line under each table repeats the notation that the table uses.
Document fields
| Field | Type | Required | Description |
|---|---|---|---|
| spec | string | ✓ | Names the version of the DAR specification that the document follows. daana dar check shows it on its Spec: line; Daana reads nothing else from it.Allowed values: dar/v1.0 |
| anchor | object (exactly 1 key) | ✓ | Names what the document declares its outputs on, with exactly one key. Daana keeps one revision per anchor in its ledger, and default object names contain the anchor's name, such as dim__customer. Documents on the same anchor share one set of output keys. |
| anchor.entity | string | ○ | Anchors the document on an entity of the DAB model, by name. Outputs read the entity that source.dab names, or else the anchor's entity, also found as <name>_entity. daana dar check refuses an anchor whose entity the model lacks, with the error DAR012. |
| anchor.process | string | ○ | Anchors the document on a named process instead of a DAB entity. Outputs that read DAB views still read the entity that source.dab, the anchor's name or <name>_entity names. daana dar check reports neither a missing anchor entity nor an unknown source.dab, but still applies DAR017 and DAR018 to source.dab. |
| anchor.consumer | string | ○ | Anchors the document on a named consumer of published data. Its outputs must be serve.view or serve.table, and daana dar generate writes them to the dataset serve_<name>, which workspace.yaml must declare. |
| anchor.reference | string | ○ | Anchors the document on named reference data instead of a DAB entity. Outputs that read DAB views still read the entity that source.dab, the anchor's name or <name>_entity names. daana dar check reports neither a missing anchor entity nor an unknown source.dab, but still applies DAR017 and DAR018 to source.dab. |
| anchor.validation | string | ○ | Anchors the document on a named validation. The document must have a lifecycle block, a union or unified star is named <name>_<output key> instead of fct__<name>, and daana dar generate writes the outputs to the dataset <name>, which workspace.yaml must declare. |
| source | object | ○ | Names what the document reads: the DAB entity in dab and, for projections, computed references and external references, an existing table in table with its columns in attributes. |
| provides | string | ○ | fx marks the document as the source of exchange rates. A leg with fx converts amounts with the rates of this document's daily output, and compile then refuses a second document with provides: fx or one that has no daily output.Allowed values: fx |
| lifecycle | object | ○ | States whether the whole document is temporary and when it is to be removed. Daana accepts this block but does not read it. A document anchored on validation must have it. |
| scopes | name → non-empty string | ○ | Names reusable SQL row conditions. Where an output's, variant's, stream's or fact.union leg's scope, a bridge's to_scope, or a rollup's where.scope, names an entry, Daana uses its condition; any other value is used as SQL itself. |
| relationships | non-empty name → object | ○ | Relates the anchor entity to other entities, one entry per role name. The role name is also the related entity unless the entry's entity names another, and facts carry the key as <role>_key. Daana keeps the links in relationship objects, such as intm__rel_order, which keys reads. A document with an entity_assembly gets none: the assembly carries each key as <entity>_key. daana dar check refuses a fact's keys in that document, and another document's via key through it (DAR021), unless a document on the same anchor without an entity_assembly, checked together with it, declares that relationship: only then does a relationship object hold the key, and otherwise the SQL would read an object or a column that does not exist. |
| stream | object | ○ | Declares the anchor's event stream: conditions, guards, and flags evaluated on each row of the entity's history. The document's event, snapshot, and lifecycle outputs read it, and when two or more outputs name from: stream, Daana computes it once in intm__<anchor>_event. |
| outputs | name → object (at least 1 key) | ✓ | The reporting outputs of the document, keyed by a name the author chooses. The key appears in references such as <anchor>.<key> and in some default names, such as fct__<anchor>_<key> for a consolidated fact. daana dar check refuses the same key on one anchor in two files, with DAR009. |
| x_<name> | any | ○ | Daana accepts any top level key that starts with x_ and does not read it, so it can hold notes for people or other tools. |
- A
validationanchor requireslifecycle. - With a
consumeranchor, thekindof an output isserve.vieworserve.table. - With an
entity,process,referenceorvalidationanchor, thekindof an output is any kind exceptserve.viewandserve.table.
✓ = required, ○ = optional. x_<name> is any key that starts with x_. name → T is a map: each key is a name, and each value has the type T.
source fields
| Field | Type | Required | Description |
|---|---|---|---|
| dab | string | ○ | Names the DAB entity, by name or id, whose views the document reads. Without it, Daana reads the entity named like the anchor, or <anchor>_entity. daana dar check refuses a name the model lacks on an entity anchor (DAR014), documents on one anchor that resolve to different entities (DAR018), and another entity than the anchor's in a document with an entity_assembly, a bridge, a lifecycle rollup or relationships (DAR017). Daana does not read it under an output's source. |
| table | string | ○ | Names an existing table, as <schema>.<table>, that Daana selects from instead of a DAB view. A fact.projection without from reads its own source.table or else the document's; a reference.computed without legs, and lookups on a reference.external output, read the document's. Other outputs do not read it. A projection with its own source gets an object only with publish.name. |
| attributes | name → object | ○ | The columns that Daana selects from table, keyed by the name they get in the output; an entry's from names the source column when it differs. Daana reads them in the same places as table. |
✓ = required, ○ = optional. name → T is a map: each key is a name, and each value has the type T.
relationships fields
| Field | Type | Required | Description |
|---|---|---|---|
| via | string | ✓ | Reaches the entity through another relationship of this document, named by its role. Daana reads the second step as the document anchored on the middle entity declares the relationship of the same name, so apply the documents together. daana dar check refuses a role that this document does not declare, with DAR003. |
| Field | Type | Required | Description |
|---|---|---|---|
| changes | string | ✓ | never states that the anchor keeps one related entity. Daana reads one related key for each anchor, on the anchor's key alone, whatever the time of the fact, and compile refuses it unless the model relationship gives each anchor at most one related entity.Allowed values: never |
| sentinel | string | ○ | A key value that the source uses to mean no reference. Daana turns it into NULL in the relationship objects that facts read their keys from, and in the key that an entity_assembly publishes. In an incremental assembly with preserve: keys, a newer link that holds the sentinel sets the key to NULL, as a full refresh does; the key that the table already holds is kept only when the run reads no newer link for the entity. |
| on_multiple | string | ○ | Daana accepts this key but does not read it. Allowed values: first_observed, any |
| entity | string | ○ | Names the related DAB entity when it differs from the role name, which is the default. Facts still name the key column <role>_key, while an entity_assembly names it <entity>_key, and so do the projections of the assembly and their wide views. daana dar check refuses an entity that the model lacks, with DAR012, or that the model does not relate to the anchor, with DAR016. |
| keys_only | boolean | ○ | true makes the related entity keys only: outputs carry its key, and daana dar check asks for no dimension of it. Check on a directory then refuses picks from it in wide, with DAR004, and compile refuses lookups that read its attributes. |
| Field | Type | Required | Description |
|---|---|---|---|
| changes | string | ✓ | tracked states that the related entity can change. Daana keeps the link's validity intervals and reads the related key that holds at the fact's time, so a fact dated before the link became valid gets no key.Allowed values: tracked |
| sentinel | string | ○ | A key value that the source uses to mean no reference. Daana turns it into NULL in the relationship objects that facts read their keys from, and in the key that an entity_assembly publishes. In an incremental assembly with preserve: keys, a newer link that holds the sentinel sets the key to NULL, as a full refresh does; the key that the table already holds is kept only when the run reads no newer link for the entity. |
| entity | string | ○ | Names the related DAB entity when it differs from the role name, which is the default. Facts still name the key column <role>_key, while an entity_assembly names it <entity>_key, and so do the projections of the assembly and their wide views. daana dar check refuses an entity that the model lacks, with DAR012, or that the model does not relate to the anchor, with DAR016. |
| keys_only | boolean | ○ | true makes the related entity keys only: outputs carry its key, and daana dar check asks for no dimension of it. Check on a directory then refuses picks from it in wide, with DAR004, and compile refuses lookups that read its attributes. |
✓ = required, ○ = optional. An entry takes one of these forms.
kind: dimension fields
| Field | Type | Required | Description |
|---|---|---|---|
| kind | string | ✓ | Makes the output a type 2 dimension: one row per version of the anchor entity, with valid_from and valid_to. Daana names it dim__<anchor>.Allowed values: dimension |
| description | string | ○ | Describes the output in prose. daana dar check warns and daana dar lint fails when an output has none. Daana does not put it in the generated SQL, and changing only this text gives the anchor no new revision. |
| backdated | boolean | ○ | With true, each entity's first version in the dimension starts at 0001-01-01 00:00:00, or at the history_start constant of workspace.yaml, instead of at its effective timestamp, so a query at an earlier time finds that version. The default, false, starts it at its effective timestamp. |
| dedup | boolean | ○ | With true, Daana keeps one row for each entity and effective timestamp before it builds the versions, so a duplicate load of one instant gives one version. Which of the duplicates it keeps is not defined. The default, false, keeps every row. The latest object is not affected. |
| delete_handling | boolean | ○ | With true, Daana drops the versions in which the entity's deletion attribute, by default the one ending in _is_deleted_in_source, is not 0, in the dimension and its latest object, and leaves that attribute out of the columns. Without this key, Daana does this whenever the entity has such an attribute. daana dar check refuses it, set to either value, on an entity without one (DAR019). |
| latest | string | ○ | view adds a second object with each entity's current version, named like the dimension with __latest appended, and table creates that object as a table. none, the default, adds no such object. daana dar check on a directory refuses a reference to <anchor>.<output>.latest when it has none, with DAR007. Bridges, and wide picks with join: latest, read that object, and daana dar check on a directory refuses them when the entity's dimension there has none (DAR021).Allowed values: none, view, table |
| attributes | "all" or list of string | ○ | Selects the attributes that become columns of the dimension and its latest object. all, the default, takes every attribute of the DAB entity, and a list takes the named attributes in its order. daana dar check refuses a listed name that is not an attribute of the entity named by source.dab, with DAR015. |
| scope | non-empty string or list of string | ○ | Daana does not use this key on a dimension, which holds every version of every entity, but changing it gives the anchor a new revision on the next daana dar apply. |
| describe | name → string | ○ | Holds descriptions of the output's columns by column name. Daana accepts this block but does not read it, so the texts reach no generated object. |
| describe_extra | name → string | ○ | Holds additional descriptions of the output's columns by column name. Daana accepts this block but does not read it, so the texts reach no generated object. |
| descriptions | name → string | ○ | Holds descriptions by column or flag name. Daana accepts this block but does not read it, so the texts reach no generated object. |
| checks | name → (string or object) | ○ | Data quality checks on the output, by check name. daana dar apply runs them on DuckDB after it creates the outputs, on the output's main object and not on a __latest or __wide companion. Apply on another target and daana dar generate refuse a document that has checks. |
| publish | object | ○ | Overrides where Daana publishes the output. name replaces dim__<anchor>, and the latest companion becomes <name>__latest; dataset sets the workspace.yaml target that daana dar generate writes to. Bridges and wide views still join the dimension under its default names, in the default dataset: daana dar check on a directory refuses a bridge or wide view of a dimension renamed with name (DAR021). |
| lifecycle | object | ○ | States whether the output is temporary and when it is to be removed. Daana accepts this block but does not read it. |
| family | string or object | ○ | Puts the output in a named family, given as a string or as name with as. A fact.consolidated with members creates one output per member and dimension, and a fact.union with legs.members adds one leg per member. Without such a reader, it does not change the SQL, but changing it gives the anchor a new revision. |
| family.name | string | ✓ | Names the family that the output belongs to, as the string form of family does. |
| family.as | string | ✓ | The value that %{metric} takes when a members template expands for this output, as in its name_template. Compile refuses a template whose family has a member without as; Daana never derives the value from the output key. |
| hide | list of string | ○ | daana dar check accepts this list, but Daana does not read it: every attribute that attributes selects stays a column. |
| x_<name> | any | ○ | Daana accepts any output key that starts with x_ and does not read it. |
✓ = required, ○ = optional. x_<name> is any key that starts with x_. name → T is a map: each key is a name, and each value has the type T. A nested field marked required is required when its parent is written as an object.
kind: fact.state fields
| Field | Type | Required | Description |
|---|---|---|---|
| kind | string | ✓ | fact.event gives one row per history row of the stream, with its flags, in fct__<anchor>_event. fact.state gives one row per entity at its axis timestamp, in fct__<anchor>. fact.projection selects columns from the output in from or from a source table.Allowed values: fact.event, fact.state, fact.projection |
| description | string | ○ | Describes the output in prose. daana dar check warns and daana dar lint fails when an output has none. Daana does not put it in the generated SQL, and changing only this text gives the anchor no new revision. |
| from | string | ○ | On a fact.projection, names an output of the same document to select from. Without publish.name, the projection takes that output's name, so daana dar check refuses it (DAR020) unless the output is an entity_assembly. Check on a directory refuses another document's output (DAR021), which Daana would plan without SQL. On a fact.event, two or more outputs with from: stream, a fact.state included although it does not read the stream, make Daana compute the stream once in intm__<anchor>_event. |
| source | object | ○ | On a fact.projection without from, names the table to select from and its columns, in place of the document's source, but only when it has table: without table, Daana reads the document's source and ignores these attributes; Daana creates the projection only when publish.name names it. Daana does not read dab here. A fact.event or fact.state does not compile source; changing it only gives the anchor a new revision. |
| scope | non-empty string or list of string | ○ | Filters the output's rows, by a name under scopes or an SQL condition. A fact.event filters its stream rows and a fact.projection its source rows; a fact.state does not use it, but changing it gives the anchor a new revision. A stream scope replaces an event's when fewer than two outputs name from: stream. Daana ignores the list form. |
| axis | object | ○ | The time that dates each row. A fact.state adds it as a column, reads its keys at it, and by default leaves out rows dated today; with keys it needs one, as keys describes. A fact.projection names an existing column with it for exclude_today and its wide view. A fact.event is always dated by fact_ts, the effective timestamp of its stream row; it reads name only for its wide view and generate's default partition, so daana dar check refuses another name there (DAR021). |
| conditions | name → non-empty string | ○ | On a fact.event, names SQL conditions on each entity's stream rows in time order, where {prev.column} reads the entity's previous row; a flag with from fires where its condition holds. Daana uses them only when the document's stream declares no conditions and fewer than two outputs read from: stream. A fact.state or fact.projection does not compile them. |
| guards | name → non-empty string | ○ | Daana does not read guards on an output: a flag's unless reads only the guards of the document's stream, and daana dar check refuses an unless that names an output guard (DAR019). |
| flags | "all" or (name → object) or list of string | ○ | On a fact.event, chooses the 0/1 flag columns: all or no flags takes every flag of the document's stream, a list the named ones, and a map defines flags when the stream has none and fewer than two outputs read from: stream. daana dar check refuses a named flag that nothing computes (DAR021), and an event with no flag or condition (DAR020) unless two or more outputs read from: stream. A fact.state computes map entries with expr on the entity's current row, check refuses from entries (DAR019), and Daana ignores a list or all. A fact.projection ignores flags. |
| derive | name → object | ○ | Adds named columns computed from SQL expressions. On a fact.state, {axis} stands for the axis column and {lookup.column} for a column of a lookup. On a fact.event, Daana computes them on each stream row, where {prev.column} reads the entity's previous row. On a fact.projection, the derived columns come before the listed columns, or after the source's columns when columns is omitted. |
| measures | list of (string or object) | ○ | Lists the output's measures. A fact.state or fact.event selects them as it selects columns and lists them first among the fact columns of its wide view. A fact.projection does not select them; only its wide view lists them. On a fact.event whose document stream lists no columns, daana dar check refuses a measure that is not also among its columns (DAR021), unless two or more outputs read from: stream. |
| columns | list of string | ○ | Lists the columns to select. A fact.state reads them from the anchor entity's current row, and a fact.event from each stream row, so with a document stream they must be among its columns, and daana dar check refuses one that is not (DAR021) unless two or more outputs read from: stream; daana dar check refuses a name the entity lacks (DAR015). On a fact.projection, omitted columns select every column except drop, and without from, source.attributes replaces them when present. |
| drop | list of string | ○ | On a fact.projection, removes the named columns: from columns, or, without columns, from every column of its source. A fact.event or fact.state does not compile it; changing it only gives the anchor a new revision. |
| keys | list of string or (name → object) | ○ | Lists relationship roles whose keys Daana adds as <role>_key columns: for changes: never the current key, for tracked the key valid at the row's time. A via role is read in two steps, each as its own document declares it, or at the row's time without the middle document. A fact.state with keys needs an axis, the time it reads them at: daana dar check refuses one without (DAR020), unless the document's relationships are all changes: never and it has a fact.state with lookups or a wide view with join: latest, which makes Daana read the keys on the anchor's key alone. In a document with an entity_assembly, daana dar check refuses the keys of a fact.state and a fact.event (DAR021), as relationships describes. On a fact.projection, a list adds no column, and a map adds computed keys only without from. |
| lookups | name → object | ○ | On a fact.state, each entry joins another output on that output's grain, and derive reads the joined row as {name.column}. A fact.event or fact.projection does not compile lookups, but daana dar check on a directory refuses a from that does not resolve (DAR007). |
| wide | object | ○ | Adds the view <fact>__wide: the fact's rows with dimension columns joined on their keys. The axis, the anchor key, and the relationship keys come first, then the picked columns, then the other fact columns. A fact.state needs an axis; a fact.projection needs an axis, an anchor key, and its column list, from columns, source.attributes, or an entity_assembly. |
| describe | name → string | ○ | Holds descriptions of the output's columns by column name. Daana accepts this block but does not read it, so the texts reach no generated object. |
| describe_extra | name → string | ○ | Holds additional descriptions of the output's columns by column name. Daana accepts this block but does not read it, so the texts reach no generated object. |
| descriptions | name → string | ○ | Holds descriptions by column or flag name. Daana accepts this block but does not read it, so the texts reach no generated object. |
| checks | name → (string or object) | ○ | Data quality checks on the output, by check name. daana dar apply runs them on DuckDB after it creates the outputs, on the output's main object and not on a __latest or __wide companion. Apply on another target and daana dar generate refuse a document that has checks. |
| grain | list of string | ○ | Lists the columns that identify one row of this output. Daana reads it only when a lookups entry names this output: the lookup joins on these columns, in order. It changes nothing in this output's own SQL. |
| exclude_today | boolean or non-empty string | ○ | Drops the rows dated today or later by the time axis. A fact.event does so by default, a fact.state by default when it has an axis, and a fact.projection only with true, which needs axis.name, or by default when it reads an entity_assembly. A string counts as false. daana dar check requires the key when axis is derived, with DAR002. |
| delete_handling | boolean | ○ | On a fact.state, true keeps only rows not deleted in the source, and false keeps them all. Without it, Daana filters when the entity has a deletion attribute, by default one ending in _is_deleted_in_source; when it has none, daana dar check refuses either value (DAR019). A fact.event or fact.projection does not compile it; changing it only gives the anchor a new revision. |
| partition | non-empty string or object | ○ | Sets the BigQuery partitioning of the table that daana dar generate writes. Without it, generate partitions an event fact by the month of axis.name, fact_ts by default, a state fact by month only when its axis.expr uses eff_tmstp or end_of_day, and a projection of an entity_assembly by the assembly's partitioning. daana dar apply does not use it, but changing it gives the anchor a new revision, and generate refuses it with materialize: view. |
| cluster | list of string | ○ | Sets the BigQuery clustering columns of the table that daana dar generate writes. Without it, generate clusters an event or state fact by <anchor>_key, and a projection of an entity_assembly takes the assembly's declared cluster, if any. daana dar apply does not use it, but changing it gives the anchor a new revision, and generate refuses it with materialize: view. |
| materialize | string | ○ | table makes the output a table and view a view; without it, daana dar apply makes a view and daana dar generate a Dataform table. Apply treats a __wide companion the same way; generate always writes it as a view. An applied table holds what the last apply wrote. daana dar apply refuses to change a published view to a table, or a table to a view, on every database: set this before the output's first apply, or drop the published object and apply again.Allowed values: table, view |
| publish | object | ○ | Overrides where Daana publishes the output. name replaces the default object name, and a __wide companion becomes <name>__wide; dataset sets the workspace.yaml target that daana dar generate writes to. Daana creates an object for a fact.projection with its own source and no from only when it has name. |
| lifecycle | object | ○ | States whether the output is temporary and when it is to be removed. Daana accepts this block but does not read it. |
| family | string or object | ○ | Puts the output in a named family, given as a string or as name with as. A fact.consolidated with members creates one output per member and dimension, and a fact.union with legs.members adds one leg per member. Without such a reader, it does not change the SQL, but changing it gives the anchor a new revision. |
| family.name | string | ✓ | Names the family that the output belongs to, as the string form of family does. |
| family.as | string | ✓ | The value that %{metric} takes when a members template expands for this output, as in its name_template. Compile refuses a template whose family has a member without as; Daana never derives the value from the output key. |
| prior_guards | name → non-empty string | ○ | Daana accepts this key but does not read it. |
| x_<name> | any | ○ | Daana accepts any output key that starts with x_ and does not read it. |
✓ = required, ○ = optional. x_<name> is any key that starts with x_. name → T is a map: each key is a name, and each value has the type T. A nested field marked required is required when its parent is written as an object.
axis fields
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | ○ | Names the axis column. On a fact.state it holds expr, or is an existing column when expr is omitted; with expr alone it is fact_ts. On a fact.projection it is an existing column; reading an entity_assembly, it defaults to the assembly's attribute ending in _start_ts. A fact.unified_star names its time column with it, fact_ts by default. A fact.event keeps fact_ts, and daana dar check refuses another name (DAR021) when its wide view or generate's default partition would read it. |
| expr | string | ○ | The SQL expression that dates each row of a fact.state, which Daana selects as the axis column. When it uses the effective timestamp, eff_tmstp by default, the state reads the anchor's history view and keeps each entity's latest row. Other kinds do not compile it. An expression other than a column name or end_of_day(column) needs an explicit exclude_today, or daana dar check refuses it (DAR002).Allowed values: non-empty |
| description | string | ○ | Describes the axis for readers of the document. Daana does not read it. |
✓ = required, ○ = optional
measures fields
measures: list of (string or object)
| Field | Type | Required | Description |
|---|---|---|---|
| [].name | string | ✓ | Names the column that holds the measure. A fact.state or fact.event selects it as it selects columns, and a fact.unified_star stage selects it from its source, with NULL in stages that lack it. A fact.projection does not select its measures; only its wide view lists them. |
| [].additivity | "additive" or "non_additive" or object with the key semi_additive | ○ | States how the measure adds up. Daana accepts this key on a measure but does not read it. |
| [].description | string | ○ | Describes the measure for readers of the document. Daana does not read it. |
| [].ai_context | object | ○ | Holds hints for AI assistants about the measure. Daana does not read it. |
✓ = required, ○ = optional. [] stands for each item of a list. A nested field marked required is required when its parent is written as an object.
wide fields
| Field | Type | Required | Description |
|---|---|---|---|
| dims | name → (list of string or object) | ✓ | Names, under each key, an entity whose dimension Daana joins into the wide view, with the columns to add. The key is the anchor or an entity whose key column, such as customer_key, the fact carries. A list gives the columns with a pit join; an object sets pick and join. daana dar check on a directory refuses a keys_only entity (DAR004). |
| dims.<name>.pick | list of string | ✓ | Lists the dimension's columns to add to the wide view, in order. daana dar check refuses a name that the dimension does not publish (DAR015). On a fact.state or fact.event, a pick replaces the fact column of the same name; on the other kinds, the duplicate name fails compile. |
| dims.<name>.join | string | ○ | pit, the default, joins the dimension version valid at the row's axis time, such as fact_ts on a fact.event. latest joins the entity's current version from dim__<entity>__latest on the key alone. That view exists only when the dimension sets latest: daana dar check on a directory refuses a latest join when the entity's dimension there has none, and any join of a dimension renamed with publish.name (DAR021).Allowed values: pit, latest |
| dims.<name>.alias | name → string | ○ | Daana accepts this key but does not read it: the wide view keeps the name of each picked column. |
| dims.<name>.descriptions | name → string | ○ | Describes the picked columns. Daana accepts this key but does not read it. |
| drop_keys | list of string | ○ | Removes the named key columns, such as order_key, from the wide view, while its joins still use them. On a fact.lifecycle, the keys_at columns count as key columns. Compile fails on a name that is not a key column of the wide view. |
| drop | list of string | ○ | Removes the named fact columns that follow the picked columns, such as measures, columns, derived columns, and flags, from the wide view. Compile fails on a name that the wide view does not carry there. |
✓ = required, ○ = optional. <name> stands for a key the author names. name → T is a map: each key is a name, and each value has the type T. A nested field marked required is required when its parent is written as an object.
kind: fact.consolidated fields
| Field | Type | Required | Description |
|---|---|---|---|
| kind | string | ✓ | fact.consolidated aggregates its legs to one row per combination of the grain columns, in fct__<anchor>_<key> after the output key. reference.computed computes a reference table from its legs or from the document's source.table, in intm__<anchor>_<key>.Allowed values: fact.consolidated, reference.computed |
| description | string | ○ | Describes the output in prose. daana dar check warns and daana dar lint fails when an output has none. Daana does not put it in the generated SQL, and changing only this text gives the anchor no new revision. |
| grain | list of string | ○ | Lists the output's grain columns. A fact.consolidated groups the combined legs by them, uses them as the default spine keys, and takes a grain column outside the spine from a leg's grain_keys. In a reference.computed, each leg groups by them and binds each one by a key with its name or a unique suffix of it. |
| currency | string | ○ | Names the target currency of every leg fx conversion, as a text value. Compile refuses a leg with fx when the output has no currency. alignment.currency replaces it. |
| spine | object | ○ | Sets how a fact.consolidated builds its spine: the distinct key combinations that every leg is joined to. A reference.computed reads only driving, which it requires when it has legs. |
| alignment | object | ○ | Holds rules for a fact.consolidated that apply across its legs: B2B exclusion, market resolution, and the target currency. A reference.computed uses only its currency. |
| legs | name → object | ○ | Names the sources the output combines, each by a leg name. A fact.consolidated aggregates each leg to the spine keys, left joins all legs to the spine, and sums each aggregate to the grain; compile refuses it without legs. A reference.computed groups each leg by the grain and left joins the others to the spine.driving leg; without legs, it computes windows. |
| post | object | ○ | Holds the lookups and derive that Daana applies after it combines the legs. Its derive replaces the output's derive when both are set. |
| post.lookups | name → object | ○ | In a fact.consolidated, joins other outputs to the aggregated rows, matching each key to the target output's grain; derive reads their columns as {lookup.column}. A reference.computed does not use it in the SQL, but changing it gives the anchor a new revision on the next daana dar apply. |
| post.derive | name → object | ○ | Adds named SQL expressions as columns like the output's derive, and replaces that block when both are set. |
| windows | object | ○ | On a reference.computed without legs, adds window columns over the rows of the document's source.table; every source row stays in the output. On a fact.consolidated, or a reference.computed with legs, Daana does not use it in the SQL, but changing it gives the anchor a new revision on the next daana dar apply. |
| derive | name → object | ○ | Adds named SQL expressions as columns after the others. In a fact.consolidated, they read the aggregated rows and a lookup column as {lookup.column}; in a reference.computed, the leg results or the window columns. post.derive replaces this block when both are set. |
| drop | list of string | ○ | On a fact.consolidated or reference.computed, Daana does not use drop in the SQL, but changing it gives the anchor a new revision on the next daana dar apply. |
| descriptions | name → string | ○ | Holds descriptions by column or flag name. Daana accepts this block but does not read it, so the texts reach no generated object. |
| checks | name → (string or object) | ○ | Data quality checks on the output, by check name. daana dar apply runs them on DuckDB after it creates the outputs, on the output's main object and not on a __latest or __wide companion. Apply on another target and daana dar generate refuse a document that has checks. |
| members | object with the key family | ○ | Makes a fact.consolidated a template: Daana creates one output for each member of the family and each dimensions value, and publishes no object for the template itself. A bare %{metric} as a leg's fact or from reads the member. daana dar check refuses members on a reference.computed (DAR019). |
| name_template | string | ○ | Names each output that a template creates, and its object: %{metric} becomes the member's family.as and %{dimension} a dimensions value, and the result must be an identifier. Compile refuses a template without members, name_template, and dimensions together, and daana dar check refuses name_template on a reference.computed (DAR019). |
| dimensions | list of string | ○ | Lists the values of %{dimension}: a template creates one output for each member and value. Without members and name_template, Daana does not use it in the SQL, but changing it gives the anchor a new revision on the next daana dar apply. |
| family | string or object | ○ | Puts the output in a named family, given as a string or as name with as. A fact.consolidated with members creates one output per member and dimension, and a fact.union with legs.members adds one leg per member. An output that has members itself does not read its own family. |
| family.name | string | ✓ | Names the family that the output belongs to, as the string form of family does. |
| family.as | string | ✓ | The value that %{metric} takes when a members template expands for this output, as in its name_template. Compile refuses a template whose family has a member without as; Daana never derives the value from the output key. |
| exclude_today | boolean or non-empty string | ○ | On a fact.consolidated, Daana does not use it in the SQL, but changing it gives the anchor a new revision. On a reference.computed, each leg that reads dab drops rows whose leg date is today or later by default, and false or any string turns that off. Daana reads the cut from that date as a column name, alone or inside one or more of parentheses, CAST(<column> AS DATE), CAST(<column> AS TIMESTAMP), CAST(<column> AS DATETIME), DATE(<column>), LAST_DAY(<column>), and END_OF_DAY(<column>); one name may qualify the column, as in <name>.<column>. It compares the column itself. daana dar check refuses a date it cannot read that way while the cut is on (DAR019): set exclude_today: false, or write the date in one of those forms. A leg without a date has no cut. |
| partition | non-empty string or object | ○ | Sets the BigQuery partitioning of the table that daana dar generate writes. Without it, generate partitions a fact.consolidated by the first grain column that is a spine key and does not end in _key, other than account_market, whatever its type, and leaves a reference.computed unpartitioned. daana dar apply does not use it, but changing it gives the anchor a new revision, and generate refuses it with materialize: view. |
| cluster | list of string | ○ | Sets the BigQuery clustering columns of the table that daana dar generate writes. Without it, generate clusters a fact.consolidated by its first two spine or grain columns and leaves a reference.computed unclustered. daana dar apply does not use it, but changing it gives the anchor a new revision, and generate refuses it with materialize: view. |
| materialize | string | ○ | table makes the output a table and view a view; without it, daana dar apply makes a view and daana dar generate a Dataform table. On a validation anchor, generate writes the outputs of a members template as views. An applied table holds what the last apply wrote. daana dar apply refuses to change a published view to a table, or a table to a view, on every database: set this before the output's first apply, or drop the published object and apply again.Allowed values: table, view |
| publish | object | ○ | Overrides where Daana publishes the output. On a fact.consolidated, name replaces fct__<anchor>_<key>. On a reference.computed, daana dar check refuses name (DAR019): Daana would plan the object without SQL. dataset sets the workspace.yaml target that daana dar generate writes to. |
| lifecycle | object | ○ | States whether the output is temporary and when it is to be removed. Daana accepts this block but does not read it. |
| x_<name> | any | ○ | Daana accepts any output key that starts with x_ and does not read it. |
✓ = required, ○ = optional. x_<name> is any key that starts with x_. name → T is a map: each key is a name, and each value has the type T. A nested field marked required is required when its parent is written as an object.
spine fields
| Field | Type | Required | Description |
|---|---|---|---|
| keys | list of string | ○ | Lists the spine columns of a fact.consolidated, grain by default: Daana collects their distinct values from every leg and left joins each leg to them, and clusters generated Dataform SQLX by the first two unless cluster is set. A reference.computed does not use it in the SQL, but changing it gives the anchor a new revision on the next daana dar apply. |
| floor | name → string | ○ | Maps a spine column to its lowest value: Daana drops spine rows below it. A YYYY-MM-DD value is a date; any other value is an SQL expression. A reference.computed does not use it in the SQL, but changing it gives the anchor a new revision on the next daana dar apply. |
| ceiling | name → string | ○ | Daana accepts this key but does not read it, so no upper bound applies to the spine. |
| null_safe | list of string | ○ | Lists spine columns that Daana joins with IS NOT DISTINCT FROM, so a NULL in a leg matches a NULL in the spine. A template adds the %{dimension} column when it is a spine key. A reference.computed does not use it in the SQL, but changing it gives the anchor a new revision on the next daana dar apply. |
| driving | string | ○ | On a reference.computed with legs, names the leg whose rows make the output: Daana takes the grain columns from it and left joins the other legs on the grain, and compile requires it. On a fact.consolidated, Daana does not use it in the SQL, but changing it gives the anchor a new revision on the next daana dar apply. |
✓ = required, ○ = optional. name → T is a map: each key is a name, and each value has the type T.
legs fields
| Field | Type | Required | Description |
|---|---|---|---|
| fact | string | ○ | In a fact.consolidated, names the published fact the leg reads, as <anchor>.<output>; add .wide for its wide companion or a grain name for a periodic snapshot. No other third part and no fourth part is read: daana dar check on a directory and compile refuse them, .latest and .Wide among them (DAR007). table takes precedence. daana dar check refuses fact on a reference.computed leg (DAR019). |
| from | string | ○ | In a fact.consolidated, Daana reads it like fact, which takes precedence, except that a periodic snapshot read with from gives its grain_keys from the snapshot itself. In a reference.computed, it names a published output of the same document, and the leg reads it instead of dab. |
| dab | string or object | ○ | In a reference.computed, names the DAB entity the leg reads from its latest view, and Daana drops rows dated today or later by the leg's date, as exclude_today describes. A fact.consolidated does not use dab in the SQL, and daana dar check refuses a leg there without fact, from, or table (DAR020). |
| table | string | ○ | In a fact.consolidated, names an external table, such as <dataset>.<table>, that the leg reads directly; it takes precedence over fact and from. A reference.computed does not use it in the SQL, and daana dar check refuses a leg there without from or dab (DAR020). |
| attributes | name → object | ○ | Daana accepts this block but does not read it. |
| at | string | ○ | On a fact.consolidated or reference.computed leg, Daana does not use at in the SQL, but changing it gives the anchor a new revision on the next daana dar apply. |
| scope | non-empty string or list of string | ○ | On a fact.consolidated or reference.computed leg, Daana does not use scope in the SQL, so it filters no rows, but changing it gives the anchor a new revision on the next daana dar apply. |
| map | name → string | ○ | On a fact.consolidated or reference.computed leg, Daana does not use map in the SQL, but changing it gives the anchor a new revision on the next daana dar apply. |
| date | string | ○ | Gives the SQL expression for the leg's date, which fx uses for its rate; without it, Daana uses the leg's one month or *_month grain column. In a fact.consolidated, it fills the first grain column that is also a spine key. On a reference.computed leg that reads dab, it decides the cut of exclude_today, which Daana reads from a column name, alone or inside one or more of parentheses, CAST(<column> AS DATE), CAST(<column> AS TIMESTAMP), CAST(<column> AS DATETIME), DATE(<column>), LAST_DAY(<column>), and END_OF_DAY(<column>); one name may qualify the column, as in <name>.<column>. daana dar check refuses a date it cannot read that way while exclude_today is on (DAR019).Allowed values: non-empty |
| fx | object | ○ | Converts the leg's sum aggregates to the output currency with rates from the daily output of the one document that declares provides: fx. Compile refuses it without an output currency or a date, and on an unaggregated leg. |
| grain_keys | list of string | ○ | In a fact.consolidated, lists grain columns only this leg carries; Daana keeps its rows unaggregated, and at most one leg may do this. From a periodic snapshot that the leg names with fact, a name without _key comes from its anchor's dimension at snapshot_ts. A reference.computed does not use it in the SQL, but changing it gives the anchor a new revision on the next daana dar apply. |
| aggregates | name → object | ○ | Names the leg's aggregates; each key is an output column name unless the aggregate is hidden. |
| x_<name> | any | ○ | Daana accepts any key that starts with x_ as an extension and does not read it: it binds no grain column, and changing it gives the anchor no new revision. |
| <name> | non-empty string or object with the key expr or object with the key via | ○ | Binds a grain column of the output, named by the key, to a value of the leg: a column of its source, an SQL expression in expr, or an attribute of a related entity in via. A reference.computed computes the grain column from it, matching the key to the grain column with that name or a unique suffix of it. A fact.consolidated does not use the value: it selects each spine column under its own name, but changing it gives the anchor a new revision. |
✓ = required, ○ = optional. <name> stands for a key the author names. x_<name> is any key that starts with x_. name → T is a map: each key is a name, and each value has the type T.
aggregates fields
| Field | Type | Required | Description |
|---|---|---|---|
| expr | string | ✓ | Gives the column or SQL expression that Daana aggregates, read from the leg's source. For a reference.computed leg that reads dab, daana dar check can report DAR015 when a bare column name is not a column of that entity.Allowed values: non-empty |
| agg | string | ✓ | Names the function Daana applies to expr within the leg, grouped by the leg's grain. A fact.consolidated then sums the leg results to its own grain, and sums the values of an unaggregated leg directly. daana dar check refuses count_distinct (DAR019): Daana does not build it.Allowed values: sum, count, count_distinct, min, max, avg |
| filters | list of string | ○ | Lists conditions on the leg's rows. On a fact.consolidated leg that Daana aggregates, a row that fails a condition is left out of the aggregate, whatever its agg, and a group in which no row passes gives 0 for sum and count, and NULL for min, max, and avg. A bare column name means the column equals 1; market_matches_spine keeps the leg unaggregated, each value only on the spine row with the leg's market. On a leg kept unaggregated, by market_matches_spine or by grain_keys, Daana does not apply agg: the fact sums the leg's values, and a row that fails a condition adds 0. A reference.computed leg does not apply filters, and daana dar check refuses them there (DAR019): write the condition into expr. |
| fx | "none" or object | ○ | none keeps this aggregate unconverted when its leg has fx; an aggregate other than sum on a converting leg needs it. daana dar check refuses the object form (DAR019). |
| hidden | boolean | ○ | Computes the aggregate but leaves it out of the output columns, so derive can still use it. |
| additivity | "additive" or "non_additive" or object with the key semi_additive | ○ | In a fact.consolidated, compile refuses every value except {semi_additive: last_within_period}, and that value does not change the SQL. A reference.computed does not use it in the SQL. |
| description | string | ○ | Describes the column for readers of the document. Daana does not read it. |
| ai_context | object | ○ | Holds hints for AI assistants about the column. Daana does not read it. |
✓ = required, ○ = optional
ai_context fields
| Field | Type | Required | Description |
|---|---|---|---|
| synonyms | list of string | ○ | Other names for the item, for AI assistants. Daana does not read it. |
| instructions | string | ○ | Guidance for AI assistants on how to use the item. Daana does not read it. |
| examples | list of string | ○ | Examples of the item for AI assistants. Daana does not read it. |
✓ = required, ○ = optional
checks fields
checks: name → (string or object)
| Field | Type | Required | Description |
|---|---|---|---|
| <name>.expr | string | ✓ | The SQL condition that the output must meet, evaluated once over the whole output, so it is built from aggregates such as COUNT or SUM. The check passes only when it is TRUE; NULL fails. {self} names this output, and {<anchor>.<output>} names another one. |
| <name>.description | string | ○ | Describes the check. Daana stores it with the check in the ledger but shows it in no apply message, and changing it gives the anchor a new revision. |
| <name>.over | string | ○ | Only output works: the condition runs once over the whole output. rows is the default when over is omitted or the check is a plain string, and daana dar check refuses it (DAR019): write over: output.Allowed values: rows, output |
| <name>.severity | string | ○ | error, the default, makes daana dar apply fail when the condition does not hold: the new outputs are already in place, and the ledger keeps the previously active revision. warn prints a warning, and the apply continues.Allowed values: warn, error |
✓ = required, ○ = optional. <name> stands for a key the author names. name → T is a map: each key is a name, and each value has the type T. A nested field marked required is required when its parent is written as an object.
In the specification, not explained yet
The bookstore documents use measures and columns, spine, the keys of a legs entry and ai_context. This page does not explain these keys yet. The same holds for where Daana shows a description and for the list of attribute names that attributes allows.
The lists below come from the full DAR specification. They hold the fields and output kinds that no bookstore document uses, in the notation of the field tables above.
| Block | Fields |
|---|---|
| kinds | fact.event, fact.projection, fact.periodic_snapshot, fact.lifecycle, fact.union, fact.unified_star, bridge, entity_assembly, reference.computed, reference.static, reference.external, serve.view, serve.table |
top level and anchor | anchor.process, anchor.consumer, anchor.reference, anchor.validation, provides, lifecycle, scopes, stream |
source | table, attributes |
| a relationship | sentinel, on_multiple, entity, keys_only |
kind: dimension | backdated, dedup, delete_handling, scope, describe, describe_extra, descriptions, publish, lifecycle, family, hide |
kind: fact.state | from, source, scope, conditions, guards, flags, derive, drop, lookups, describe, describe_extra, descriptions, grain, exclude_today, delete_handling, partition, cluster, publish, lifecycle, family, prior_guards |
kind: fact.consolidated | currency, alignment, post, windows, derive, drop, descriptions, members, name_template, dimensions, family, exclude_today, partition, cluster, publish, lifecycle |
axis | name |
| a measure | [].ai_context |
keys, the map form | <name>.expr, <name>.description |
wide | dims.<name>.pick, dims.<name>.join, dims.<name>.alias, dims.<name>.descriptions, drop_keys, drop |
spine | keys, floor, ceiling, null_safe |
| a leg | from, dab, table, attributes, at, scope, map, fx, grain_keys |
| an aggregate | filters, fx, hidden, additivity |
ai_context | instructions, examples |
These values and forms are also not explained here:
latest: noneandlatest: table- A measure written as a plain name
additivity: non_additive, and the form ofadditivitywith the keysemi_additive- A check written as a string
over: rows- Any
aggvalue other thansum - A key that starts with
x_
Next steps
The following pages cover using a DAR document and looking up its commands:
- Chapter 7: Reporting with DAR walks through daily revenue, customer history and output checks.
- Apply DAR on a deployed DAB covers applying documents, failed checks, restoring outputs and previewing SQL.
- Generate DAR for Dataform covers generating BigQuery SQLX and running it through Dataform.
- DAR command reference lists the commands, arguments and flags.