diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index c369a579e..f9babee20 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -104,7 +104,7 @@ from metricflow.plan_conversion.sql_join_builder import ( AnnotatedSqlDataSet, ColumnEqualityDescription, - SqlQueryPlanJoinBuilder, + SqlPlanJoinBuilder, ) from metricflow.protocols.sql_client import SqlEngine from metricflow.sql.optimizer.optimization_levels import ( @@ -539,7 +539,7 @@ def visit_join_over_time_range_node(self, node: JoinOverTimeRangeNode) -> SqlDat join_spec = self._choose_instance_for_time_spine_join(agg_time_dimension_instances).spec annotated_parent = parent_data_set.annotate(alias=parent_data_set_alias, metric_time_spec=join_spec) annotated_time_spine = time_spine_data_set.annotate(alias=time_spine_data_set_alias, metric_time_spec=join_spec) - join_desc = SqlQueryPlanJoinBuilder.make_cumulative_metric_time_range_join_description( + join_desc = SqlPlanJoinBuilder.make_cumulative_metric_time_range_join_description( node=node, metric_data_set=annotated_parent, time_spine_data_set=annotated_time_spine ) @@ -598,7 +598,7 @@ def visit_join_on_entities_node(self, node: JoinOnEntitiesNode) -> SqlDataSet: right_data_set_alias = self._next_unique_table_alias() # Build join description. - sql_join_desc = SqlQueryPlanJoinBuilder.make_base_output_join_description( + sql_join_desc = SqlPlanJoinBuilder.make_base_output_join_description( left_data_set=AnnotatedSqlDataSet(data_set=from_data_set, alias=from_data_set_alias), right_data_set=AnnotatedSqlDataSet(data_set=right_data_set, alias=right_data_set_alias), join_description=join_description, @@ -1110,7 +1110,7 @@ def visit_combine_aggregated_outputs_node(self, node: CombineAggregatedOutputsNo aliases_seen = [from_data_set.alias] for join_data_set in join_data_sets: joins_descriptions.append( - SqlQueryPlanJoinBuilder.make_join_description_for_combining_datasets( + SqlPlanJoinBuilder.make_join_description_for_combining_datasets( from_data_set=from_data_set, join_data_set=join_data_set, join_type=join_type, @@ -1397,7 +1397,7 @@ def visit_semi_additive_join_node(self, node: SemiAdditiveJoinNode) -> SqlDataSe ) join_data_set_alias = self._next_unique_table_alias() - sql_join_desc = SqlQueryPlanJoinBuilder.make_column_equality_sql_join_description( + sql_join_desc = SqlPlanJoinBuilder.make_column_equality_sql_join_description( right_source_node=row_filter_sql_select_node, left_source_alias=from_data_set_alias, right_source_alias=join_data_set_alias, @@ -1444,7 +1444,7 @@ def visit_join_to_time_spine_node(self, node: JoinToTimeSpineNode) -> SqlDataSet # Build join expression. join_column_name = self._column_association_resolver.resolve_spec(node.join_on_time_dimension_spec).column_name - join_description = SqlQueryPlanJoinBuilder.make_join_to_time_spine_join_description( + join_description = SqlPlanJoinBuilder.make_join_to_time_spine_join_description( node=node, time_spine_alias=time_spine_alias, agg_time_dimension_column_name=join_column_name, @@ -1760,7 +1760,7 @@ def visit_join_conversion_events_node(self, node: JoinConversionEventsNode) -> S constant_property_column_names.append((base_property_col_name, conversion_property_col_name)) # Builds the join conditions that is required for a successful conversion - sql_join_description = SqlQueryPlanJoinBuilder.make_join_conversion_join_description( + sql_join_description = SqlPlanJoinBuilder.make_join_conversion_join_description( node=node, base_data_set=AnnotatedSqlDataSet( data_set=base_data_set, diff --git a/metricflow/plan_conversion/sql_join_builder.py b/metricflow/plan_conversion/sql_join_builder.py index 284e20360..ea7bd5c77 100644 --- a/metricflow/plan_conversion/sql_join_builder.py +++ b/metricflow/plan_conversion/sql_join_builder.py @@ -46,8 +46,8 @@ class ColumnEqualityDescription: treat_nulls_as_equal: bool = False -class SqlQueryPlanJoinBuilder: - """Helper class for constructing various join components in a SqlQueryPlan.""" +class SqlPlanJoinBuilder: + """Helper class for constructing various join components`.""" @staticmethod def make_column_equality_sql_join_description( @@ -194,11 +194,11 @@ def make_base_output_join_description( ) ) - validity_conditions = SqlQueryPlanJoinBuilder._make_validity_window_on_conditions( + validity_conditions = SqlPlanJoinBuilder._make_validity_window_on_conditions( left_data_set=left_data_set, right_data_set=right_data_set, join_description=join_description ) - return SqlQueryPlanJoinBuilder.make_column_equality_sql_join_description( + return SqlPlanJoinBuilder.make_column_equality_sql_join_description( right_source_node=right_data_set.data_set.checked_sql_select_node, left_source_alias=left_data_set.alias, right_source_alias=right_data_set.alias, @@ -253,7 +253,7 @@ def _make_validity_window_on_conditions( window_end_dimension_name = right_data_set.data_set.column_association_for_time_dimension( join_description.validity_window.window_end_dimension ).column_name - window_join_condition = SqlQueryPlanJoinBuilder._make_time_window_join_condition( + window_join_condition = SqlPlanJoinBuilder._make_time_window_join_condition( left_source_alias=left_data_set.alias, left_source_time_dimension_name=left_data_set_time_dimension_name, right_source_alias=right_data_set.alias, @@ -331,7 +331,7 @@ def make_join_description_for_combining_datasets( len(column_names) > 0 ), "Attempting to do a FULL OUTER JOIN to combine metrics, but no columns were provided for join keys!" equality_exprs = [ - SqlQueryPlanJoinBuilder._make_equality_expression_for_full_outer_join( + SqlPlanJoinBuilder._make_equality_expression_for_full_outer_join( table_aliases_for_coalesce, join_data_set.alias, colname ) for colname in column_names @@ -352,7 +352,7 @@ def make_join_description_for_combining_datasets( ColumnEqualityDescription(left_column_alias=name, right_column_alias=name, treat_nulls_as_equal=True) for name in column_names ] - return SqlQueryPlanJoinBuilder.make_column_equality_sql_join_description( + return SqlPlanJoinBuilder.make_column_equality_sql_join_description( right_source_node=join_data_set.data_set.checked_sql_select_node, left_source_alias=from_data_set.alias, right_source_alias=join_data_set.alias, @@ -484,12 +484,12 @@ def make_join_conversion_join_description( under the condition of being within the time range and other conditions (such as constant properties). This builds the join description to satisfy all those conditions. """ - window_condition = SqlQueryPlanJoinBuilder._make_time_range_window_join_condition( + window_condition = SqlPlanJoinBuilder._make_time_range_window_join_condition( base_data_set=base_data_set, time_comparison_dataset=conversion_data_set, window=node.window, ) - return SqlQueryPlanJoinBuilder.make_column_equality_sql_join_description( + return SqlPlanJoinBuilder.make_column_equality_sql_join_description( right_source_node=conversion_data_set.data_set.checked_sql_select_node, left_source_alias=base_data_set.alias, right_source_alias=conversion_data_set.alias, @@ -509,7 +509,7 @@ def make_cumulative_metric_time_range_join_description( Cumulative metrics must be joined against a time spine in a backward-looking fashion, with a range determined by a time window (delta against metric_time) and optional cumulative grain. """ - cumulative_join_condition = SqlQueryPlanJoinBuilder._make_time_range_window_join_condition( + cumulative_join_condition = SqlPlanJoinBuilder._make_time_range_window_join_condition( base_data_set=metric_data_set, time_comparison_dataset=time_spine_data_set, window=node.window,