Skip to content

Commit

Permalink
make comparison case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDee committed Nov 11, 2024
1 parent 86029bf commit a88441c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions dbt_semantic_interfaces/implementations/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _from_yaml_value(cls, input: PydanticParseableValueType) -> PydanticMetricTi
The MetricTimeWindow is always expected to be provided as a string in user-defined YAML configs.
"""
if isinstance(input, str):
return PydanticMetricTimeWindow.parse(window=input, custom_granularity_names=(), strict=False)
return PydanticMetricTimeWindow.parse(window=input.lower(), custom_granularity_names=(), strict=False)
else:
raise ValueError(
f"MetricTimeWindow inputs from model configs are expected to always be of type string, but got "
Expand All @@ -90,7 +90,7 @@ def _from_yaml_value(cls, input: PydanticParseableValueType) -> PydanticMetricTi
@property
def is_standard_granularity(self) -> bool:
"""Returns whether the window uses standard TimeGranularity."""
return self.granularity in {item.value for item in TimeGranularity}
return self.granularity.casefold() in {item.value.casefold() for item in TimeGranularity}

@property
def window_string(self) -> str:
Expand All @@ -113,7 +113,9 @@ def parse(window: str, custom_granularity_names: Sequence[str], strict: bool = T

granularity = parts[1]

valid_time_granularities = {item.value for item in TimeGranularity} | set(custom_granularity_names)
valid_time_granularities = {item.value.lower() for item in TimeGranularity} | set(
c.lower() for c in custom_granularity_names
)

# if we switched to python 3.9 this could just be `granularity = parts[0].removesuffix('s')
if granularity.endswith("s") and granularity[:-1] in valid_time_granularities:
Expand Down

0 comments on commit a88441c

Please sign in to comment.