Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
igorlukanin opened this issue Jan 24, 2025 · 0 comments
Labels
bug Something isn't working data modeling

Comments

@igorlukanin
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working data modeling
Projects
None yet
Development

No branches or pull requests

1 participant