-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add implementation for QueryParameter
- Loading branch information
1 parent
1c8a21e
commit 8a63473
Showing
3 changed files
with
26 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
from typing import Optional | ||
|
||
from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity | ||
|
||
from metricflow.naming.linkable_spec_name import StructuredLinkableSpecName | ||
from metricflow.time.date_part import DatePart | ||
|
||
|
||
@dataclass(frozen=True) | ||
class DimensionQueryParameter: | ||
"""Time dimension requested in a query.""" | ||
|
||
name: str | ||
grain: Optional[TimeGranularity] = None | ||
date_part: Optional[DatePart] = None | ||
|
||
def __post_init__(self) -> None: # noqa: D | ||
parsed_name = StructuredLinkableSpecName.from_name(self.name) | ||
if parsed_name.time_granularity: | ||
raise ValueError("Must use object syntax for `grain` parameter if `date_part` is requested.") |
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