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): Reference granularities in a proxy dimension #8664

Merged
merged 25 commits into from
Sep 15, 2024

Conversation

KSDaemon
Copy link
Member

@KSDaemon KSDaemon commented Sep 2, 2024

This PR introduces the ability to reference the time dimension granularity in dimension definition like this:

.....
    dimensions:
      - name: created_at_half_year
        sql: "{created_at.half_year}"
        type: string

      - name: created_at_fiscal_year_feb
        sql: "{created_at.fiscal_year_by_1st_feb}"
        type: string

      - name: created_at
        sql: created_at
        type: time
        granularities:
          - name: half_year
            interval: 6 months
          - name: half_year_by_1st_april
            interval: 6 months
            offset: 3 months
          - name: fiscal_year_by_1st_feb
            interval: 1 year
            offset: 1 month
          - name: fiscal_year_by_15th_march
            interval: 1 year
            origin: '2024-03-15'

      - name: created_at_predefined_year
         sql: "{createdAt.year}"                   # You can refer even predefined granularities
         type: string

Then you can request those dimensions like any other: add filters, order, or whatever.
Smth like this:

{
  "measures": [
    "base_orders.count"
  ],
  "order": {
    "base_orders.count": "desc"
  },
  "timeDimensions": [
    {
      "dimension": "base_orders.created_at",
      "dateRange": [
        "2019-01-01",
        "2021-01-02"
      ]
    }
  ],
  "dimensions": [
    "base_orders.created_at_half_year"
  ]
}

The resulting query will automatically include the necessary code as if requesting the time dimension with specified granularity.

Depends on:

Check List

  • Tests has 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 Sep 2, 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 15, 2024 9:53pm
examples-react-d3 ⬜️ Ignored (Inspect) Visit Preview Sep 15, 2024 9:53pm
examples-react-dashboard ⬜️ Ignored (Inspect) Visit Preview Sep 15, 2024 9:53pm
examples-react-data-table ⬜️ Ignored (Inspect) Visit Preview Sep 15, 2024 9:53pm
examples-react-highcharts ⬜️ Ignored (Inspect) Visit Preview Sep 15, 2024 9:53pm
examples-react-material-ui ⬜️ Ignored (Inspect) Visit Preview Sep 15, 2024 9:53pm
examples-react-pivot-table ⬜️ Ignored (Inspect) Visit Preview Sep 15, 2024 9:53pm
examples-vue-query-builder ⬜️ Ignored (Inspect) Visit Preview Sep 15, 2024 9:53pm

@KSDaemon KSDaemon changed the base branch from master to custom-granularities September 2, 2024 18:35
@KSDaemon KSDaemon force-pushed the proxy-granularities branch 2 times, most recently from 6f5243a to 61ae0e1 Compare September 3, 2024 08:34
@KSDaemon KSDaemon marked this pull request as ready for review September 3, 2024 10:12
@KSDaemon KSDaemon requested a review from a team as a code owner September 3, 2024 10:12
@KSDaemon KSDaemon force-pushed the proxy-granularities branch 6 times, most recently from 3783c3d to 3ba312d Compare September 6, 2024 05:24
@KSDaemon KSDaemon requested review from a team as code owners September 6, 2024 05:24
@KSDaemon KSDaemon force-pushed the proxy-granularities branch 4 times, most recently from 56a522f to 0b3fa7d Compare September 6, 2024 12:07
@KSDaemon KSDaemon force-pushed the custom-granularities branch 2 times, most recently from 2841d34 to 8dde82c Compare September 9, 2024 09:14
@KSDaemon KSDaemon force-pushed the proxy-granularities branch 3 times, most recently from 079f64d to aee2599 Compare September 9, 2024 11:31
@paveltiunov paveltiunov changed the title proxy granularities feat: Reference granularities in a proxy dimension Sep 15, 2024
@KSDaemon KSDaemon changed the title feat: Reference granularities in a proxy dimension feat(schema-compiler): Reference granularities in a proxy dimension Sep 15, 2024
@KSDaemon KSDaemon merged commit b7674f3 into master Sep 15, 2024
49 checks passed
@KSDaemon KSDaemon deleted the proxy-granularities branch September 15, 2024 22:25
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