Skip to content

Commit

Permalink
Updated StructuredLinkableSpecName and removed DunderedNameFormatter
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDee committed Nov 11, 2024
1 parent 2eaf47a commit bec5255
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class DunderNamingScheme(QueryItemNamingScheme):
"""A naming scheme using the dundered name syntax.
TODO: Consolidate with StructuredLinkableSpecName / DunderedNameFormatter.
TODO: Consolidate with StructuredLinkableSpecName.
"""

_INPUT_REGEX = re.compile(r"\A[a-z]([a-z0-9_])*[a-z0-9]\Z")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
DimensionCallParameterSet,
TimeDimensionCallParameterSet,
)
from dbt_semantic_interfaces.naming.dundered import DunderedNameFormatter
from dbt_semantic_interfaces.protocols.protocol_hint import ProtocolHint
from dbt_semantic_interfaces.protocols.query_interface import (
QueryInterfaceDimension,
Expand All @@ -18,6 +17,7 @@
from typing_extensions import override

from metricflow_semantics.errors.error_classes import InvalidQuerySyntax
from metricflow_semantics.naming.linkable_spec_name import StructuredLinkableSpecName
from metricflow_semantics.query.group_by_item.filter_spec_resolution.filter_location import WhereFilterLocation
from metricflow_semantics.query.group_by_item.filter_spec_resolution.filter_spec_lookup import (
FilterSpecResolutionLookUp,
Expand Down Expand Up @@ -134,15 +134,19 @@ def __init__( # noqa
spec_resolution_lookup: FilterSpecResolutionLookUp,
where_filter_location: WhereFilterLocation,
rendered_spec_tracker: RenderedSpecTracker,
custom_granularity_names: Sequence[str],
):
self._column_association_resolver = column_association_resolver
self._resolved_spec_lookup = spec_resolution_lookup
self._where_filter_location = where_filter_location
self._rendered_spec_tracker = rendered_spec_tracker
self._custom_granularity_names = custom_granularity_names

def create(self, name: str, entity_path: Sequence[str] = ()) -> WhereFilterDimension:
"""Create a WhereFilterDimension."""
structured_name = DunderedNameFormatter.parse_name(name.lower())
structured_name = StructuredLinkableSpecName.from_name(
name.lower(), custom_granularity_names=self._custom_granularity_names
)

return WhereFilterDimension(
column_association_resolver=self._column_association_resolver,
Expand All @@ -151,5 +155,7 @@ def create(self, name: str, entity_path: Sequence[str] = ()) -> WhereFilterDimen
rendered_spec_tracker=self._rendered_spec_tracker,
element_name=structured_name.element_name,
entity_links=tuple(EntityReference(entity_link_name.lower()) for entity_link_name in entity_path)
+ structured_name.entity_links,
+ tuple(
EntityReference(entity_link_name.lower()) for entity_link_name in structured_name.entity_link_names
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from dbt_semantic_interfaces.call_parameter_sets import (
EntityCallParameterSet,
)
from dbt_semantic_interfaces.naming.dundered import DunderedNameFormatter
from dbt_semantic_interfaces.protocols.protocol_hint import ProtocolHint
from dbt_semantic_interfaces.protocols.query_interface import QueryInterfaceEntity, QueryInterfaceEntityFactory
from dbt_semantic_interfaces.references import EntityReference
Expand All @@ -14,6 +13,7 @@
from typing_extensions import override

from metricflow_semantics.errors.error_classes import InvalidQuerySyntax
from metricflow_semantics.naming.linkable_spec_name import StructuredLinkableSpecName
from metricflow_semantics.query.group_by_item.filter_spec_resolution.filter_location import WhereFilterLocation
from metricflow_semantics.query.group_by_item.filter_spec_resolution.filter_spec_lookup import (
FilterSpecResolutionLookUp,
Expand Down Expand Up @@ -103,7 +103,7 @@ def __init__( # noqa

def create(self, entity_name: str, entity_path: Sequence[str] = ()) -> WhereFilterEntity:
"""Create a WhereFilterEntity."""
structured_name = DunderedNameFormatter.parse_name(entity_name.lower())
structured_name = StructuredLinkableSpecName.from_name(entity_name.lower(), custom_granularity_names=())

return WhereFilterEntity(
column_association_resolver=self._column_association_resolver,
Expand All @@ -112,5 +112,7 @@ def create(self, entity_name: str, entity_path: Sequence[str] = ()) -> WhereFilt
rendered_spec_tracker=self._rendered_spec_tracker,
element_name=structured_name.element_name,
entity_links=tuple(EntityReference(entity_link_name.lower()) for entity_link_name in entity_path)
+ structured_name.entity_links,
+ tuple(
EntityReference(entity_link_name.lower()) for entity_link_name in structured_name.entity_link_names
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def create_from_where_filter_intersection( # noqa: D102
spec_resolution_lookup=self._spec_resolution_lookup,
where_filter_location=filter_location,
rendered_spec_tracker=rendered_spec_tracker,
custom_granularity_names=self._semantic_model_lookup.custom_granularity_names,
)
time_dimension_factory = WhereFilterTimeDimensionFactory(
column_association_resolver=self._column_association_resolver,
Expand Down

0 comments on commit bec5255

Please sign in to comment.