-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render EXTRACT columns in semantic model dataset by default
- Loading branch information
1 parent
a26a412
commit 66c988f
Showing
6 changed files
with
150 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from __future__ import annotations | ||
|
||
from enum import Enum | ||
|
||
from dbt_semantic_interfaces.enum_extension import assert_values_exhausted | ||
from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity | ||
|
||
|
||
class DatePart(Enum): | ||
"""Date parts able to be extracted from a time dimension. | ||
TODO: add support for hour, minute, second once those granularities are available | ||
""" | ||
|
||
YEAR = "year" | ||
QUARTER = "quarter" | ||
MONTH = "month" | ||
WEEK = "week" | ||
WEEKDAY = "weekday" | ||
DAYOFYEAR = "dayofyear" | ||
DAY = "day" | ||
|
||
def to_int(self) -> int: | ||
"""Convert to an int so that the size of the granularity can be easily compared.""" | ||
if self is DatePart.DAY: | ||
return TimeGranularity.DAY.to_int() | ||
elif self is DatePart.WEEKDAY: | ||
return TimeGranularity.DAY.to_int() | ||
elif self is DatePart.DAYOFYEAR: | ||
return TimeGranularity.DAY.to_int() | ||
elif self is DatePart.WEEK: | ||
return TimeGranularity.WEEK.to_int() | ||
elif self is DatePart.MONTH: | ||
return TimeGranularity.MONTH.to_int() | ||
elif self is DatePart.QUARTER: | ||
return TimeGranularity.QUARTER.to_int() | ||
elif self is DatePart.YEAR: | ||
return TimeGranularity.YEAR.to_int() | ||
else: | ||
assert_values_exhausted(self) |