-
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.
Replace TimeDimensionTransformNode with AliasSpecsNode
Also fixes a small issue where we were prematurely filtering out columns in that node. This is what you see in the snapshot changes. It should not impact optimized queries.
- Loading branch information
1 parent
1beeb58
commit da044a3
Showing
81 changed files
with
1,411 additions
and
556 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
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
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,59 @@ | ||
from __future__ import annotations | ||
|
||
from abc import ABC | ||
from dataclasses import dataclass | ||
from typing import Sequence, Tuple | ||
|
||
from metricflow_semantics.dag.id_prefix import IdPrefix, StaticIdPrefix | ||
from metricflow_semantics.dag.mf_dag import DisplayedProperty | ||
from metricflow_semantics.specs.instance_spec import InstanceSpec | ||
from metricflow_semantics.visitor import VisitorOutputT | ||
|
||
from metricflow.dataflow.dataflow_plan import DataflowPlanNode | ||
from metricflow.dataflow.dataflow_plan_visitor import DataflowPlanNodeVisitor | ||
|
||
|
||
@dataclass(frozen=True, eq=False) | ||
class AliasSpecsNode(DataflowPlanNode, ABC): | ||
"""Change the columns matching the key specs to match the value specs.""" | ||
|
||
change_specs: Sequence[Tuple[InstanceSpec, InstanceSpec]] | ||
|
||
def __post_init__(self) -> None: # noqa: D105 | ||
super().__post_init__() | ||
assert len(self.change_specs) > 0, "Must have at least one value in change_specs for AliasSpecsNode." | ||
|
||
@staticmethod | ||
def create( # noqa: D102 | ||
parent_node: DataflowPlanNode, change_specs: Sequence[Tuple[InstanceSpec, InstanceSpec]] | ||
) -> AliasSpecsNode: | ||
return AliasSpecsNode(parent_nodes=(parent_node,), change_specs=change_specs) | ||
|
||
@classmethod | ||
def id_prefix(cls) -> IdPrefix: # noqa: D102 | ||
return StaticIdPrefix.DATAFLOW_NODE_ALIAS_SPECS_ID_PREFIX | ||
|
||
def accept(self, visitor: DataflowPlanNodeVisitor[VisitorOutputT]) -> VisitorOutputT: # noqa: D102 | ||
return visitor.visit_alias_specs_node(self) | ||
|
||
@property | ||
def description(self) -> str: # noqa: D102 | ||
return """Change Column Aliases""" | ||
|
||
@property | ||
def displayed_properties(self) -> Sequence[DisplayedProperty]: # noqa: D102 | ||
return tuple(super().displayed_properties) + (DisplayedProperty("change_specs", self.change_specs),) | ||
|
||
@property | ||
def parent_node(self) -> DataflowPlanNode: # noqa: D102 | ||
return self.parent_nodes[0] | ||
|
||
def functionally_identical(self, other_node: DataflowPlanNode) -> bool: # noqa: D102 | ||
return isinstance(other_node, self.__class__) and other_node.change_specs == self.change_specs | ||
|
||
def with_new_parents(self, new_parent_nodes: Sequence[DataflowPlanNode]) -> AliasSpecsNode: # noqa: D102 | ||
assert len(new_parent_nodes) == 1, "AliasSpecsNode accepts exactly one parent node." | ||
return AliasSpecsNode.create( | ||
parent_node=new_parent_nodes[0], | ||
change_specs=self.change_specs, | ||
) |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.