Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move node dataset resolver subquery ids into a separate namespace #1280

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20240613-171930.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Refine subquery ID generation. This may result in changing subquery ids for rendered SQL.
time: 2024-06-13T17:19:30.939376-07:00
custom:
Author: tlento
Issue: "1280"
1 change: 1 addition & 0 deletions metricflow-semantics/metricflow_semantics/dag/id_prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class StaticIdPrefix(IdPrefix, Enum, metaclass=EnumMetaClassHelper):

TIME_SPINE_SOURCE = "time_spine_src"
SUB_QUERY = "subq"
NODE_RESOLVER_SUB_QUERY = "nr_subq"

@property
@override
Expand Down
11 changes: 11 additions & 0 deletions metricflow/dataflow/builder/node_data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

from typing import TYPE_CHECKING, Dict, Optional, Sequence

from metricflow_semantics.dag.id_prefix import StaticIdPrefix
from metricflow_semantics.dag.sequential_id import SequentialIdGenerator
from metricflow_semantics.mf_logging.runtime import log_block_runtime
from metricflow_semantics.specs.column_assoc import ColumnAssociationResolver
from typing_extensions import override

from metricflow.dataflow.dataflow_plan import (
DataflowPlanNode,
Expand Down Expand Up @@ -93,3 +96,11 @@ def copy(self) -> DataflowPlanNodeOutputDataSetResolver:
semantic_manifest_lookup=self._semantic_manifest_lookup,
_node_to_output_data_set=dict(self._node_to_output_data_set),
)

@override
def _next_unique_table_alias(self) -> str:
"""Return the next unique table alias to use in generating queries.

This uses a separate prefix in order to minimize subquery ID thrash.
"""
return SequentialIdGenerator.create_next_id(StaticIdPrefix.NODE_RESOLVER_SUB_QUERY).str_value
Loading
Loading