Skip to content

Commit

Permalink
Support sub-daily granularity in YAML configs (#286)
Browse files Browse the repository at this point in the history
Resolves #818

### Description
Enable sub-daily granularities in YAML specs (for time dimensions &
cumulative metric windows).


### Checklist

- [x] I have read [the contributing
guide](https://github.com/dbt-labs/dbt-semantic-interfaces/blob/main/CONTRIBUTING.md)
and understand what's expected of me
- [x] I have signed the
[CLA](https://docs.getdbt.com/docs/contributor-license-agreements)
- [x] This PR includes tests, or tests are not required/relevant for
this PR
- [x] I have run `changie new` to [create a changelog
entry](https://github.com/dbt-labs/dbt-semantic-interfaces/blob/main/CONTRIBUTING.md#adding-a-changelog-entry)
  • Loading branch information
courtneyholcomb authored Jun 7, 2024
1 parent ead98b2 commit bb201df
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20240606-190154.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Enable sub-daily granularity in YAML wherever TimeGranularity is supported.
time: 2024-06-06T19:01:54.71895-07:00
custom:
Author: courtneyholcomb
Issue: "818"
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,23 @@
"properties": {
"time_granularity": {
"enum": [
"NANOSECOND",
"MICROSECOND",
"MILLISECOND",
"SECOND",
"MINUTE",
"HOUR",
"DAY",
"WEEK",
"MONTH",
"QUARTER",
"YEAR",
"nanosecond",
"microsecond",
"millisecond",
"second",
"minute",
"hour",
"day",
"week",
"month",
Expand Down Expand Up @@ -677,11 +689,23 @@
},
"grain": {
"enum": [
"NANOSECOND",
"MICROSECOND",
"MILLISECOND",
"SECOND",
"MINUTE",
"HOUR",
"DAY",
"WEEK",
"MONTH",
"QUARTER",
"YEAR",
"nanosecond",
"microsecond",
"millisecond",
"second",
"minute",
"hour",
"day",
"week",
"month",
Expand Down
14 changes: 13 additions & 1 deletion dbt_semantic_interfaces/parsing/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,19 @@
window_aggregation_type_values = ["MIN", "MAX"]
window_aggregation_type_values += [x.lower() for x in window_aggregation_type_values]

time_granularity_values = ["DAY", "WEEK", "MONTH", "QUARTER", "YEAR"]
time_granularity_values = [
"NANOSECOND",
"MICROSECOND",
"MILLISECOND",
"SECOND",
"MINUTE",
"HOUR",
"DAY",
"WEEK",
"MONTH",
"QUARTER",
"YEAR",
]
time_granularity_values += [x.lower() for x in time_granularity_values]

dimension_type_values = ["CATEGORICAL", "TIME"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ semantic_model:
- name: ds
type: time
type_params:
time_granularity: day
time_granularity: second
- name: ds_partitioned
type: time
is_partition: true
Expand Down

0 comments on commit bb201df

Please sign in to comment.