Skip to content

Commit

Permalink
Rename SqlQueryPlanJoinBuilder.
Browse files Browse the repository at this point in the history
  • Loading branch information
plypaul committed Dec 18, 2024
1 parent 1907e7d commit daea2ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions metricflow/plan_conversion/dataflow_to_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
20 changes: 10 additions & 10 deletions metricflow/plan_conversion/sql_join_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit daea2ed

Please sign in to comment.