Skip to content

Commit

Permalink
Clean up granularity input matching logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tlento committed Sep 13, 2024
1 parent c9abc2a commit a16495a
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,21 @@ def create_time_dimension(
grain_parsed_from_name = (
group_by_item_name.time_granularity.value if group_by_item_name.time_granularity else None
)
grain_from_param = time_granularity_name
if grain_parsed_from_name and grain_from_param and grain_from_param != grain_parsed_from_name:
inputs_are_mismatched = (
grain_parsed_from_name is not None
and time_granularity_name is not None
and time_granularity_name != grain_parsed_from_name
)

if inputs_are_mismatched:
raise ParseWhereFilterException(
f"Received different grains in `time_dimension_name` parameter ('{time_dimension_name}') "
f"and `time_granularity_name` parameter ('{time_granularity_name}'). Remove the grain suffix "
f"(`{grain_parsed_from_name}`) from the time dimension name and use the `time_granularity_name` "
"parameter to specify the intendend grain."
)

time_granularity_name = grain_parsed_from_name or grain_from_param
time_granularity_name = grain_parsed_from_name or time_granularity_name

return TimeDimensionCallParameterSet(
time_dimension_reference=TimeDimensionReference(element_name=group_by_item_name.element_name),
Expand Down

0 comments on commit a16495a

Please sign in to comment.