From a16495a36425a7514987a585e89e337dc946c25c Mon Sep 17 00:00:00 2001 From: tlento Date: Fri, 13 Sep 2024 14:42:37 -0700 Subject: [PATCH] Clean up granularity input matching logic --- .../parsing/where_filter/parameter_set_factory.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dbt_semantic_interfaces/parsing/where_filter/parameter_set_factory.py b/dbt_semantic_interfaces/parsing/where_filter/parameter_set_factory.py index 919c5aa8..c59dc016 100644 --- a/dbt_semantic_interfaces/parsing/where_filter/parameter_set_factory.py +++ b/dbt_semantic_interfaces/parsing/where_filter/parameter_set_factory.py @@ -73,8 +73,13 @@ 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 " @@ -82,7 +87,7 @@ def create_time_dimension( "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),