-
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.
Update callsites to cast str to TimeGranularity as custom grain is no…
…t supported yet
- Loading branch information
1 parent
3a40926
commit 7c0f846
Showing
5 changed files
with
59 additions
and
11 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
metricflow-semantics/metricflow_semantics/errors/custom_grain_not_supported.py
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,20 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Optional | ||
|
||
from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity | ||
|
||
|
||
def error_if_not_standard_grain(input_granularity: str, context: Optional[str] = None) -> TimeGranularity: | ||
"""Cast input grainularity string to TimeGranularity, otherwise error. | ||
TODO: Not needed once, custom grain is supported for most things. | ||
""" | ||
try: | ||
time_grain = TimeGranularity(input_granularity) | ||
except ValueError: | ||
error_msg = f"Received a non-standard time granularity, which is not supported at the moment, received: {input_granularity}." | ||
if context: | ||
error_msg += f"\nContext: {context}" | ||
raise ValueError(error_msg) | ||
return time_grain |
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