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

feat(schema-compiler): Allow passing function that returns an array of time dimensions as pre-aggregation timeDimensions property #9125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KSDaemon
Copy link
Member

@KSDaemon KSDaemon commented Jan 22, 2025

This allows to pass a function as a pre-aggregation timeDimensions property like this:

  cube(`Users`, {
    sql: `SELECT * FROM public.users`,

    preAggregations: {
      dynamicMultiple: {
        dimensions: [CUBE.status],
        measures: [CUBE.count],
        timeDimensions: (CUBE) => [
          {dimension: CUBE.createdAt, granularity: 'day'},
          {dimension: CUBE.modifiedAt, granularity: 'day'},
        ]
      },
    },

You can also use dynamicity inside concrete time dimension, like this:

  cube(`Users`, {
    sql: `SELECT * FROM public.users`,

    preAggregations: {
      dynamicMultiple: {
        dimensions: [CUBE.status],
        measures: [CUBE.count],
        timeDimensions: [
          {dimension: (CUBE) => CUBE.createdAt, granularity: 'day'},
          {dimension: (CUBE) => CUBE.modifiedAt, granularity: 'day'},
        ]
      },
    },

Check List

  • Tests have been run in packages where changes made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

@KSDaemon KSDaemon marked this pull request as ready for review January 22, 2025 17:21
@KSDaemon KSDaemon requested a review from a team as a code owner January 22, 2025 17:21
@KSDaemon KSDaemon force-pushed the feat/dynamic-timedims-in-preagg branch 3 times, most recently from 293f833 to efea541 Compare January 24, 2025 17:31
…f time dimensions as pre-aggregation timeDimensions property
@KSDaemon KSDaemon force-pushed the feat/dynamic-timedims-in-preagg branch from efea541 to 12a65ce Compare January 27, 2025 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants