From b865f97b538717d335b5f55d5de56d4d7a06795d Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 10 May 2024 12:30:29 -0700 Subject: [PATCH] Add snapshots for query parser. --- ...time_dimension_name_validation__result.txt | 16 +++ ...ved_metric_with_offset_parsing__result.txt | 10 ++ ...rder_by_granularity_conversion__result.txt | 19 ++++ ...r_by_granularity_no_conversion__result.txt | 16 +++ ...validate_where_constraint_dims__result.txt | 105 ++++++++++++++++++ .../test_query_parser__result.txt | 24 ++++ ..._case_insensitivity_with_names__result.txt | 24 ++++ ...itivity_with_parameter_objects__result.txt | 24 ++++ ...uery_parser_with_object_params__result.txt | 24 ++++ ...me_range_constraint_conversion__result.txt | 17 +++ 10 files changed, 279 insertions(+) create mode 100644 metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_cumulative_metric_agg_time_dimension_name_validation__result.txt create mode 100644 metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_derived_metric_with_offset_parsing__result.txt create mode 100644 metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_order_by_granularity_conversion__result.txt create mode 100644 metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_order_by_granularity_no_conversion__result.txt create mode 100644 metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_parse_and_validate_where_constraint_dims__result.txt create mode 100644 metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_query_parser__result.txt create mode 100644 metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_query_parser_case_insensitivity_with_names__result.txt create mode 100644 metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_query_parser_case_insensitivity_with_parameter_objects__result.txt create mode 100644 metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_query_parser_with_object_params__result.txt create mode 100644 metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_time_range_constraint_conversion__result.txt diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_cumulative_metric_agg_time_dimension_name_validation__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_cumulative_metric_agg_time_dimension_name_validation__result.txt new file mode 100644 index 0000000000..fb49793461 --- /dev/null +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_cumulative_metric_agg_time_dimension_name_validation__result.txt @@ -0,0 +1,16 @@ +ParseQueryResult( + query_spec=MetricFlowQuerySpec( + metric_specs=(MetricSpec(element_name='revenue_cumulative'),), + time_dimension_specs=( + TimeDimensionSpec( + element_name='ds', + entity_links=(EntityReference(element_name='revenue_instance'),), + time_granularity=MONTH, + ), + ), + filter_intersection=PydanticWhereFilterIntersection(), + filter_spec_resolution_lookup=FilterSpecResolutionLookUp(), + min_max_only=False, + ), + queried_semantic_models=(SemanticModelReference(semantic_model_name='revenue_source'),), +) diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_derived_metric_with_offset_parsing__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_derived_metric_with_offset_parsing__result.txt new file mode 100644 index 0000000000..4f6c6cb998 --- /dev/null +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_derived_metric_with_offset_parsing__result.txt @@ -0,0 +1,10 @@ +ParseQueryResult( + query_spec=MetricFlowQuerySpec( + metric_specs=(MetricSpec(element_name='revenue_growth_2_weeks'),), + time_dimension_specs=(TimeDimensionSpec(element_name='metric_time', time_granularity=MONTH),), + filter_intersection=PydanticWhereFilterIntersection(), + filter_spec_resolution_lookup=FilterSpecResolutionLookUp(), + min_max_only=False, + ), + queried_semantic_models=(SemanticModelReference(semantic_model_name='revenue_source'),), +) diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_order_by_granularity_conversion__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_order_by_granularity_conversion__result.txt new file mode 100644 index 0000000000..d64d104f5d --- /dev/null +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_order_by_granularity_conversion__result.txt @@ -0,0 +1,19 @@ +ParseQueryResult( + query_spec=MetricFlowQuerySpec( + metric_specs=(MetricSpec(element_name='bookings'), MetricSpec(element_name='revenue')), + time_dimension_specs=(TimeDimensionSpec(element_name='metric_time', time_granularity=MONTH),), + order_by_specs=( + OrderBySpec( + instance_spec=TimeDimensionSpec(element_name='metric_time', time_granularity=MONTH), + descending=True, + ), + ), + filter_intersection=PydanticWhereFilterIntersection(), + filter_spec_resolution_lookup=FilterSpecResolutionLookUp(), + min_max_only=False, + ), + queried_semantic_models=( + SemanticModelReference(semantic_model_name='bookings_source'), + SemanticModelReference(semantic_model_name='revenue_source'), + ), +) diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_order_by_granularity_no_conversion__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_order_by_granularity_no_conversion__result.txt new file mode 100644 index 0000000000..ae5ca2ae13 --- /dev/null +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_order_by_granularity_no_conversion__result.txt @@ -0,0 +1,16 @@ +ParseQueryResult( + query_spec=MetricFlowQuerySpec( + metric_specs=(MetricSpec(element_name='bookings'),), + time_dimension_specs=(TimeDimensionSpec(element_name='metric_time', time_granularity=DAY),), + order_by_specs=( + OrderBySpec( + instance_spec=TimeDimensionSpec(element_name='metric_time', time_granularity=DAY), + descending=False, + ), + ), + filter_intersection=PydanticWhereFilterIntersection(), + filter_spec_resolution_lookup=FilterSpecResolutionLookUp(), + min_max_only=False, + ), + queried_semantic_models=(SemanticModelReference(semantic_model_name='bookings_source'),), +) diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_parse_and_validate_where_constraint_dims__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_parse_and_validate_where_constraint_dims__result.txt new file mode 100644 index 0000000000..1c78b42533 --- /dev/null +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_parse_and_validate_where_constraint_dims__result.txt @@ -0,0 +1,105 @@ +ParseQueryResult( + query_spec=MetricFlowQuerySpec( + metric_specs=(MetricSpec(element_name='bookings'),), + time_dimension_specs=(TimeDimensionSpec(element_name='metric_time', time_granularity=DAY),), + time_range_constraint=TimeRangeConstraint( + start_time=datetime.datetime(2020, 1, 15, 0, 0), + end_time=datetime.datetime(2020, 2, 15, 0, 0), + ), + filter_intersection=PydanticWhereFilterIntersection( + where_filters=[ + PydanticWhereFilter( + where_sql_template="{{ Dimension('booking__is_instant') }} = '1'", + ), + ], + ), + filter_spec_resolution_lookup=FilterSpecResolutionLookUp( + spec_resolutions=( + FilterSpecResolution( + lookup_key=ResolvedSpecLookUpKey( + filter_location=WhereFilterLocation( + metric_references=( + MetricReference( + element_name='bookings', + ), + ), + ), + call_parameter_set=DimensionCallParameterSet( + entity_path=( + EntityReference( + element_name='booking', + ), + ), + dimension_reference=DimensionReference( + element_name='is_instant', + ), + ), + ), + where_filter_intersection=PydanticWhereFilterIntersection( + where_filters=[ + PydanticWhereFilter( + where_sql_template="{{ Dimension('booking__is_instant') }} = '1'", + ), + ], + ), + resolved_linkable_element_set=LinkableElementSet( + path_key_to_linkable_dimensions={ + ElementPathKey( + element_name='is_instant', + element_type=DIMENSION, + entity_links=( + EntityReference( + element_name='booking', + ), + ), + ): ( + LinkableDimension( + semantic_model_origin=SemanticModelReference( + semantic_model_name='bookings_source', + ), + element_name='is_instant', + dimension_type=CATEGORICAL, + entity_links=( + EntityReference( + element_name='booking', + ), + ), + join_path=SemanticModelJoinPath( + left_semantic_model_reference=SemanticModelReference( + semantic_model_name='bookings_source', + ), + ), + properties=frozenset( + 'LOCAL', + ), + ), + ), + }, + ), + spec_pattern=DimensionPattern( + parameter_set=EntityLinkPatternParameterSet( + fields_to_compare=( + ELEMENT_NAME, + ENTITY_LINKS, + ), + element_name='is_instant', + entity_links=( + EntityReference( + element_name='booking', + ), + ), + ), + ), + filter_location_path=MetricFlowQueryResolutionPath( + resolution_path_nodes=( + QueryGroupByItemResolutionNode(node_id=qr_5), + ), + ), + object_builder_str="Dimension('booking__is_instant')", + ), + ), + ), + min_max_only=False, + ), + queried_semantic_models=(SemanticModelReference(semantic_model_name='bookings_source'),), +) diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_query_parser__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_query_parser__result.txt new file mode 100644 index 0000000000..fd62a4611f --- /dev/null +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_query_parser__result.txt @@ -0,0 +1,24 @@ +ParseQueryResult( + query_spec=MetricFlowQuerySpec( + metric_specs=(MetricSpec(element_name='bookings'),), + dimension_specs=( + DimensionSpec( + element_name='is_instant', + entity_links=(EntityReference(element_name='booking'),), + ), + ), + entity_specs=(EntitySpec(element_name='listing'),), + time_dimension_specs=(TimeDimensionSpec(element_name='metric_time', time_granularity=DAY),), + order_by_specs=( + OrderBySpec( + instance_spec=TimeDimensionSpec(element_name='metric_time', time_granularity=DAY), + descending=False, + ), + OrderBySpec(instance_spec=MetricSpec(element_name='bookings'), descending=True), + ), + filter_intersection=PydanticWhereFilterIntersection(), + filter_spec_resolution_lookup=FilterSpecResolutionLookUp(), + min_max_only=False, + ), + queried_semantic_models=(SemanticModelReference(semantic_model_name='bookings_source'),), +) diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_query_parser_case_insensitivity_with_names__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_query_parser_case_insensitivity_with_names__result.txt new file mode 100644 index 0000000000..fd62a4611f --- /dev/null +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_query_parser_case_insensitivity_with_names__result.txt @@ -0,0 +1,24 @@ +ParseQueryResult( + query_spec=MetricFlowQuerySpec( + metric_specs=(MetricSpec(element_name='bookings'),), + dimension_specs=( + DimensionSpec( + element_name='is_instant', + entity_links=(EntityReference(element_name='booking'),), + ), + ), + entity_specs=(EntitySpec(element_name='listing'),), + time_dimension_specs=(TimeDimensionSpec(element_name='metric_time', time_granularity=DAY),), + order_by_specs=( + OrderBySpec( + instance_spec=TimeDimensionSpec(element_name='metric_time', time_granularity=DAY), + descending=False, + ), + OrderBySpec(instance_spec=MetricSpec(element_name='bookings'), descending=True), + ), + filter_intersection=PydanticWhereFilterIntersection(), + filter_spec_resolution_lookup=FilterSpecResolutionLookUp(), + min_max_only=False, + ), + queried_semantic_models=(SemanticModelReference(semantic_model_name='bookings_source'),), +) diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_query_parser_case_insensitivity_with_parameter_objects__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_query_parser_case_insensitivity_with_parameter_objects__result.txt new file mode 100644 index 0000000000..fd62a4611f --- /dev/null +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_query_parser_case_insensitivity_with_parameter_objects__result.txt @@ -0,0 +1,24 @@ +ParseQueryResult( + query_spec=MetricFlowQuerySpec( + metric_specs=(MetricSpec(element_name='bookings'),), + dimension_specs=( + DimensionSpec( + element_name='is_instant', + entity_links=(EntityReference(element_name='booking'),), + ), + ), + entity_specs=(EntitySpec(element_name='listing'),), + time_dimension_specs=(TimeDimensionSpec(element_name='metric_time', time_granularity=DAY),), + order_by_specs=( + OrderBySpec( + instance_spec=TimeDimensionSpec(element_name='metric_time', time_granularity=DAY), + descending=False, + ), + OrderBySpec(instance_spec=MetricSpec(element_name='bookings'), descending=True), + ), + filter_intersection=PydanticWhereFilterIntersection(), + filter_spec_resolution_lookup=FilterSpecResolutionLookUp(), + min_max_only=False, + ), + queried_semantic_models=(SemanticModelReference(semantic_model_name='bookings_source'),), +) diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_query_parser_with_object_params__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_query_parser_with_object_params__result.txt new file mode 100644 index 0000000000..fd62a4611f --- /dev/null +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_query_parser_with_object_params__result.txt @@ -0,0 +1,24 @@ +ParseQueryResult( + query_spec=MetricFlowQuerySpec( + metric_specs=(MetricSpec(element_name='bookings'),), + dimension_specs=( + DimensionSpec( + element_name='is_instant', + entity_links=(EntityReference(element_name='booking'),), + ), + ), + entity_specs=(EntitySpec(element_name='listing'),), + time_dimension_specs=(TimeDimensionSpec(element_name='metric_time', time_granularity=DAY),), + order_by_specs=( + OrderBySpec( + instance_spec=TimeDimensionSpec(element_name='metric_time', time_granularity=DAY), + descending=False, + ), + OrderBySpec(instance_spec=MetricSpec(element_name='bookings'), descending=True), + ), + filter_intersection=PydanticWhereFilterIntersection(), + filter_spec_resolution_lookup=FilterSpecResolutionLookUp(), + min_max_only=False, + ), + queried_semantic_models=(SemanticModelReference(semantic_model_name='bookings_source'),), +) diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_time_range_constraint_conversion__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_time_range_constraint_conversion__result.txt new file mode 100644 index 0000000000..e7c2d2cd60 --- /dev/null +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_query_parser.py/ParseQueryResult/test_time_range_constraint_conversion__result.txt @@ -0,0 +1,17 @@ +ParseQueryResult( + query_spec=MetricFlowQuerySpec( + metric_specs=(MetricSpec(element_name='bookings'), MetricSpec(element_name='revenue')), + time_dimension_specs=(TimeDimensionSpec(element_name='metric_time', time_granularity=MONTH),), + time_range_constraint=TimeRangeConstraint( + start_time=datetime.datetime(2020, 1, 1, 0, 0), + end_time=datetime.datetime(2020, 2, 29, 0, 0), + ), + filter_intersection=PydanticWhereFilterIntersection(), + filter_spec_resolution_lookup=FilterSpecResolutionLookUp(), + min_max_only=False, + ), + queried_semantic_models=( + SemanticModelReference(semantic_model_name='bookings_source'), + SemanticModelReference(semantic_model_name='revenue_source'), + ), +)