Skip to content

Incomplete data model validation: an array is accepted as time_dimension in a pre-aggregation definition #9138

@igorlukanin

Description

@igorlukanin

Describe the bug
In YAML-based data models, an array is accepted for the time_dimension parameter in a pre-aggregation definition. This data model compiles but fails at runtime, when the query comes.

Changing the time dimension definition to the following fixes it:

        time_dimension: CUBE.x_order_created_at

To Reproduce
Steps to reproduce the behavior:

  1. Use the following data model.
  2. Run a query.
{
  "dimensions": [
    "orders_yml.x_merchant_name"
  ],
  "timeDimensions": [],
  "order": {
    "orders_yml.x_merchant_name": "asc"
  }
}
  1. See the error.
Typename.split is not a function
TypeError: name.split is not a function
    at CubeStoreQuery.aliasName (/cube/node_modules/@cubejs-backend/schema-compiler/src/adapter/BaseQuery.js:2205:23)
    at BaseTimeDimension.unescapedAliasName (/cube/node_modules/@cubejs-backend/schema-compiler/src/adapter/BaseTimeDimension.ts:63:26)
    at /cube/node_modules/@cubejs-backend/schema-compiler/src/adapter/PreAggregations.js:1340:53
    at _map (/cube/node_modules/@cubejs-backend/schema-compiler/node_modules/ramda/src/internal/_map.js:7:19)
...

Expected behavior
This data model should fail at compile time with a clear error message.

Minimally reproducible Cube Schema

cubes:
  - name: orders_yml
    data_source: my_analytics
    sql_table: public.my_orders

    dimensions:

      - name: x_merchant_name
        sql: x_merchant_name
        type: string

      - name: x_order_created_at
        sql: x_created_at
        type: time
    
    pre_aggregations:
      - name: orders_rollup
        type: rollup
        dimensions:
          - CUBE.x_merchant_name
        time_dimension:
          - CUBE.x_order_created_at
        granularity: day

Version:
v1.1.16

Additional context
Reported by Embeddable in Slack: https://cube-js.slack.com/archives/C04KDTE2EF7/p1737652938177579

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugLEGACY. Use the Bug issue type insteaddata modeling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions