Syntax
Entities within the data model (e.g., cubes, views, etc.) should be placed under
the model folder, follow naming
conventions, and be defined using a supported
syntax.
Data model files should be placed inside the model folder. You can use the
schemaPath configuration option to override the
folder name or the repositoryFactory configuration
option to dynamically define the folder name and
data model file contents.
It's recommended to place each cube or view in a separate file, in model/cubes
and model/views folders, respectively. Example:
model
├── cubes
│ ├── orders.yml
│ ├── products.yml
│ └── users.yml
└── views
└── revenue.ymlCommon rules apply to names of entities within the data model. All names must:
- start with a letter
- consist of letters, numbers, and underscore (
_) symbols only
It is also recommended that names use snake case.
Good examples of names:
orders,stripe_invoices, orbase_payments(cubes)opportunities,cloud_accounts, orarr(views)count,avg_price, ortotal_amount_shipped(measures)name,is_shipped, orcreated_at(dimensions)main,orders_by_status, orlambda_invoices(pre-aggregations)
Cube supports two ways to define data model files: with YAML or JavaScript syntax.
YAML syntax is supported since v0.31.0.
YAML data model files should have the .yml extension, whereas JavaScript data
model files should end with .js.
It's recommended to use YAML syntax by default. Opt to JavaScript syntax when you need to have a dynamic data model.
cubes:
- name: orders
sql: >
SELECT * FROM orders, line_items WHERE orders.id = line_items.order_idSyntax comparison
YAML syntax is very similar to JavaScript syntax, with a few key differences:
- In YAML syntax, cubes, views, and context variables should be wrapped in
{}, e.g.,{FILTER_PARAMS.orders.created_at.filter('created_at')}. - In YAML syntax, string values only need to have quotes around them if they
contain special values, e.g.,
"{CUBE}.user_id = {users.id}". Special values include references toCUBEand other declared cubes,FILTER_PARAMS,COMPILE_CONTEXT, andSECURITY_CONTEXT.
Did you find this page useful?