-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write tests for metric_time filters in YAML definitions
- Loading branch information
1 parent
ec2a052
commit 99d27b0
Showing
5 changed files
with
324 additions
and
0 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
76 changes: 76 additions & 0 deletions
76
....py/MetricFlowQuerySpec/test_derived_metric_with_defined_metric_time_filter__result_0.txt
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,76 @@ | ||
MetricFlowQuerySpec( | ||
metric_specs=(MetricSpec(element_name='derived_metric_with_time_granularity_and_outer_metric_time_filter'),), | ||
filter_intersection=PydanticWhereFilterIntersection(), | ||
filter_spec_resolution_lookup=FilterSpecResolutionLookUp( | ||
spec_resolutions=( | ||
FilterSpecResolution( | ||
lookup_key=ResolvedSpecLookUpKey( | ||
filter_location=WhereFilterLocation( | ||
metric_references=( | ||
MetricReference( | ||
element_name='derived_metric_with_time_granularity_and_outer_metric_time_filter', | ||
), | ||
), | ||
), | ||
call_parameter_set=TimeDimensionCallParameterSet( | ||
time_dimension_reference=TimeDimensionReference( | ||
element_name='metric_time', | ||
), | ||
), | ||
), | ||
where_filter_intersection=PydanticWhereFilterIntersection( | ||
where_filters=[ | ||
PydanticWhereFilter( | ||
where_sql_template="{{ TimeDimension('metric_time') }} > '2020-01-01'\n", | ||
), | ||
], | ||
), | ||
resolved_linkable_element_set=LinkableElementSet( | ||
path_key_to_linkable_dimensions={ | ||
ElementPathKey( | ||
element_name='metric_time', | ||
element_type=TIME_DIMENSION, | ||
time_granularity=YEAR, | ||
): ( | ||
LinkableDimension( | ||
defined_in_semantic_model=SemanticModelReference( | ||
semantic_model_name='monthly_measures_source', | ||
), | ||
element_name='metric_time', | ||
dimension_type=TIME, | ||
join_path=SemanticModelJoinPath( | ||
left_semantic_model_reference=SemanticModelReference( | ||
semantic_model_name='monthly_measures_source', | ||
), | ||
), | ||
properties=frozenset( | ||
'DERIVED_TIME_GRANULARITY', | ||
'METRIC_TIME', | ||
), | ||
time_granularity=YEAR, | ||
), | ||
), | ||
}, | ||
), | ||
spec_pattern=TimeDimensionPattern( | ||
parameter_set=EntityLinkPatternParameterSet( | ||
fields_to_compare=( | ||
DATE_PART, | ||
ELEMENT_NAME, | ||
ENTITY_LINKS, | ||
), | ||
element_name='metric_time', | ||
), | ||
), | ||
filter_location_path=MetricFlowQueryResolutionPath( | ||
resolution_path_nodes=( | ||
QueryGroupByItemResolutionNode(node_id=qr_1), | ||
MetricGroupByItemResolutionNode(node_id=mtr_1), | ||
), | ||
), | ||
object_builder_str="TimeDimension('metric_time')", | ||
), | ||
), | ||
), | ||
min_max_only=False, | ||
) |
80 changes: 80 additions & 0 deletions
80
...erySpec/test_derived_metric_with_defined_metric_time_filter_on_input_metric__result_0.txt
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,80 @@ | ||
MetricFlowQuerySpec( | ||
metric_specs=(MetricSpec(element_name='derived_metric_with_time_granularity_and_inner_metric_time_filter'),), | ||
filter_intersection=PydanticWhereFilterIntersection(), | ||
filter_spec_resolution_lookup=FilterSpecResolutionLookUp( | ||
spec_resolutions=( | ||
FilterSpecResolution( | ||
lookup_key=ResolvedSpecLookUpKey( | ||
filter_location=WhereFilterLocation( | ||
metric_references=( | ||
MetricReference( | ||
element_name='simple_metric_with_time_granularity_and_metric_time_filter', | ||
), | ||
), | ||
), | ||
call_parameter_set=TimeDimensionCallParameterSet( | ||
time_dimension_reference=TimeDimensionReference( | ||
element_name='metric_time', | ||
), | ||
), | ||
), | ||
where_filter_intersection=PydanticWhereFilterIntersection( | ||
where_filters=[ | ||
PydanticWhereFilter( | ||
where_sql_template="{{ TimeDimension('metric_time') }} > '2020-01-01'\n", | ||
), | ||
PydanticWhereFilter( | ||
where_sql_template="{{ TimeDimension('metric_time') }} = '2020-01-01'", | ||
), | ||
], | ||
), | ||
resolved_linkable_element_set=LinkableElementSet( | ||
path_key_to_linkable_dimensions={ | ||
ElementPathKey( | ||
element_name='metric_time', | ||
element_type=TIME_DIMENSION, | ||
time_granularity=QUARTER, | ||
): ( | ||
LinkableDimension( | ||
defined_in_semantic_model=SemanticModelReference( | ||
semantic_model_name='monthly_measures_source', | ||
), | ||
element_name='metric_time', | ||
dimension_type=TIME, | ||
join_path=SemanticModelJoinPath( | ||
left_semantic_model_reference=SemanticModelReference( | ||
semantic_model_name='monthly_measures_source', | ||
), | ||
), | ||
properties=frozenset( | ||
'DERIVED_TIME_GRANULARITY', | ||
'METRIC_TIME', | ||
), | ||
time_granularity=QUARTER, | ||
), | ||
), | ||
}, | ||
), | ||
spec_pattern=TimeDimensionPattern( | ||
parameter_set=EntityLinkPatternParameterSet( | ||
fields_to_compare=( | ||
DATE_PART, | ||
ELEMENT_NAME, | ||
ENTITY_LINKS, | ||
), | ||
element_name='metric_time', | ||
), | ||
), | ||
filter_location_path=MetricFlowQueryResolutionPath( | ||
resolution_path_nodes=( | ||
QueryGroupByItemResolutionNode(node_id=qr_1), | ||
MetricGroupByItemResolutionNode(node_id=mtr_1), | ||
MetricGroupByItemResolutionNode(node_id=mtr_0), | ||
), | ||
), | ||
object_builder_str="TimeDimension('metric_time')", | ||
), | ||
), | ||
), | ||
min_max_only=False, | ||
) |
76 changes: 76 additions & 0 deletions
76
...y.py/MetricFlowQuerySpec/test_simple_metric_with_defined_metric_time_filter__result_0.txt
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,76 @@ | ||
MetricFlowQuerySpec( | ||
metric_specs=(MetricSpec(element_name='simple_metric_with_time_granularity_and_metric_time_filter'),), | ||
filter_intersection=PydanticWhereFilterIntersection(), | ||
filter_spec_resolution_lookup=FilterSpecResolutionLookUp( | ||
spec_resolutions=( | ||
FilterSpecResolution( | ||
lookup_key=ResolvedSpecLookUpKey( | ||
filter_location=WhereFilterLocation( | ||
metric_references=( | ||
MetricReference( | ||
element_name='simple_metric_with_time_granularity_and_metric_time_filter', | ||
), | ||
), | ||
), | ||
call_parameter_set=TimeDimensionCallParameterSet( | ||
time_dimension_reference=TimeDimensionReference( | ||
element_name='metric_time', | ||
), | ||
), | ||
), | ||
where_filter_intersection=PydanticWhereFilterIntersection( | ||
where_filters=[ | ||
PydanticWhereFilter( | ||
where_sql_template="{{ TimeDimension('metric_time') }} > '2020-01-01'\n", | ||
), | ||
], | ||
), | ||
resolved_linkable_element_set=LinkableElementSet( | ||
path_key_to_linkable_dimensions={ | ||
ElementPathKey( | ||
element_name='metric_time', | ||
element_type=TIME_DIMENSION, | ||
time_granularity=QUARTER, | ||
): ( | ||
LinkableDimension( | ||
defined_in_semantic_model=SemanticModelReference( | ||
semantic_model_name='monthly_measures_source', | ||
), | ||
element_name='metric_time', | ||
dimension_type=TIME, | ||
join_path=SemanticModelJoinPath( | ||
left_semantic_model_reference=SemanticModelReference( | ||
semantic_model_name='monthly_measures_source', | ||
), | ||
), | ||
properties=frozenset( | ||
'DERIVED_TIME_GRANULARITY', | ||
'METRIC_TIME', | ||
), | ||
time_granularity=QUARTER, | ||
), | ||
), | ||
}, | ||
), | ||
spec_pattern=TimeDimensionPattern( | ||
parameter_set=EntityLinkPatternParameterSet( | ||
fields_to_compare=( | ||
DATE_PART, | ||
ELEMENT_NAME, | ||
ENTITY_LINKS, | ||
), | ||
element_name='metric_time', | ||
), | ||
), | ||
filter_location_path=MetricFlowQueryResolutionPath( | ||
resolution_path_nodes=( | ||
QueryGroupByItemResolutionNode(node_id=qr_1), | ||
MetricGroupByItemResolutionNode(node_id=mtr_0), | ||
), | ||
), | ||
object_builder_str="TimeDimension('metric_time')", | ||
), | ||
), | ||
), | ||
min_max_only=False, | ||
) |