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): custom granularity support #8537

Merged
merged 84 commits into from
Sep 12, 2024
Merged

Conversation

KSDaemon
Copy link
Member

@KSDaemon KSDaemon commented Aug 5, 2024

This PR brings custom granularity support into the Cube.

Now it is possible to define any number of custom granularities for time dimension. Custom granularity maybe specified in two forms:

  • Interval + offset. You can look at this as a supercharged date_trunc version. This way you can define only intervals that are divisible by a year with no remainder (like for example2 months).
  • Interval + origin point. This is the most flexible variant. You can choose any arbitrary interval (e.g. 2 months 3 weeks 4 days 12 hours) and set the origin pivot point for calculating intervals. Origin maybe specified in date or timestamp if needed.

A few examples:

.....
dimensions:
  - name: createdAt
    sql: created_at
    type: time
    granularities:
      - name: six_months
        interval: 6 months # no offset specified, meaning the start of the year
      - name: three_months_offset
        interval: 3 months
        offset: 2 weeks # the pivot point in this case will be 15 Jan
      - name: fiscal_year_1st_april
        interval: 1 year
        origin: >  # Note that as date includes dashes, you need to escape it with quotes or use `>` variant
          2024-04-01
      - name: timestamp_origin_example
        interval: 24 days
        origin: "2024-02-15 10:15:25"

What's else inside?

  • Custom granularity support in YAML cube definitions
  • Custom granularity cube scheme validation
  • Custom granularity interval generation for rolling windows
  • Custom granularity support in BaseQuery
  • Custom granularity support for PostgeSQL
  • Custom granularity support for MySQL
  • Custom granularity support for BigQuery
  • Custom granularity support for Databricks
  • Custom granularity support for MS SQL Server
  • Custom granularity support for Snowflake
  • Custom granularity support for ClickHouse
  • Custom granularity support for DuckDB

This PR probably closes #177 and partially #8488

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

Copy link

vercel bot commented Aug 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-angular-dashboard ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 3:16pm
examples-react-d3 ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 3:16pm
examples-react-dashboard ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 3:16pm
examples-react-data-table ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 3:16pm
examples-react-highcharts ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 3:16pm
examples-react-material-ui ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 3:16pm
examples-react-pivot-table ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 3:16pm
examples-vue-query-builder ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 3:16pm

@KSDaemon KSDaemon force-pushed the custom-granularities branch 8 times, most recently from 88de386 to 96799c6 Compare August 9, 2024 21:54
@KSDaemon KSDaemon force-pushed the custom-granularities branch 10 times, most recently from 9188c84 to 2cd7934 Compare August 20, 2024 19:38
@KSDaemon KSDaemon force-pushed the custom-granularities branch 2 times, most recently from 80e0dc9 to a57ebe8 Compare August 22, 2024 12:07
@KSDaemon KSDaemon force-pushed the custom-granularities branch 7 times, most recently from 4d4b8f2 to 4ba0696 Compare August 28, 2024 11:02
@KSDaemon KSDaemon merged commit 2109849 into master Sep 12, 2024
49 checks passed
@KSDaemon KSDaemon deleted the custom-granularities branch September 12, 2024 15:42
@KSDaemon KSDaemon restored the custom-granularities branch September 12, 2024 15:48
@KSDaemon KSDaemon deleted the custom-granularities branch September 20, 2024 09:15
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.

Alternate week granularity to allow for week starting either Sunday OR Monday and other granularities
4 participants