Skip to content

Commit

Permalink
Move SqlTable and TimeSpineSource to metricflow-semantics
Browse files Browse the repository at this point in the history
Needed to allow using TimeSpineSouce in LinkableSpecResolver
  • Loading branch information
courtneyholcomb committed Jul 26, 2024
1 parent 19ecaeb commit 6a9ff9c
Show file tree
Hide file tree
Showing 32 changed files with 40 additions and 40 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

from dbt_semantic_interfaces.protocols import SemanticManifest
from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity
from metricflow_semantics.specs.time_dimension_spec import DEFAULT_TIME_GRANULARITY

from metricflow.sql.sql_table import SqlTable
from metricflow_semantics.specs.time_dimension_spec import DEFAULT_TIME_GRANULARITY
from metricflow_semantics.sql.sql_table import SqlTable

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -38,7 +38,7 @@ def create_from_manifest(semantic_manifest: SemanticManifest) -> Dict[TimeGranul
time_spine_sources = {
time_spine.primary_column.time_granularity: TimeSpineSource(
schema_name=time_spine.node_relation.schema_name,
table_name=time_spine.node_relation.relation_name,
table_name=time_spine.node_relation.alias,
db_name=time_spine.node_relation.database,
time_column_name=time_spine.primary_column.name,
time_column_granularity=time_spine.primary_column.time_granularity,
Expand Down
2 changes: 1 addition & 1 deletion metricflow/dataflow/builder/dataflow_plan_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from metricflow_semantics.specs.where_filter.where_filter_spec import WhereFilterSpec
from metricflow_semantics.specs.where_filter.where_filter_transform import WhereSpecFactory
from metricflow_semantics.sql.sql_join_type import SqlJoinType
from metricflow_semantics.sql.sql_table import SqlTable
from metricflow_semantics.time.dateutil_adjuster import DateutilTimePeriodAdjuster

from metricflow.dataflow.builder.node_data_set import DataflowPlanNodeOutputDataSetResolver
Expand Down Expand Up @@ -91,7 +92,6 @@
PredicatePushdownState,
PreJoinNodeProcessor,
)
from metricflow.sql.sql_table import SqlTable

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion metricflow/dataflow/builder/source_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
from metricflow_semantics.specs.column_assoc import ColumnAssociationResolver
from metricflow_semantics.specs.group_by_metric_spec import GroupByMetricSpec
from metricflow_semantics.specs.query_spec import MetricFlowQuerySpec
from metricflow_semantics.time.time_spine_source import TimeSpineSource

from metricflow.dataflow.dataflow_plan import DataflowPlanNode
from metricflow.dataflow.nodes.metric_time_transform import MetricTimeDimensionTransformNode
from metricflow.dataflow.nodes.read_sql_source import ReadSqlSourceNode
from metricflow.dataset.convert_semantic_model import SemanticModelToDataSetConverter
from metricflow.dataset.semantic_model_adapter import SemanticModelDataSet
from metricflow.plan_conversion.time_spine import TimeSpineSource


@dataclass(frozen=True)
Expand Down
2 changes: 1 addition & 1 deletion metricflow/dataflow/nodes/write_to_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from typing import Sequence

from metricflow_semantics.dag.id_prefix import IdPrefix, StaticIdPrefix
from metricflow_semantics.sql.sql_table import SqlTable
from metricflow_semantics.visitor import VisitorOutputT

from metricflow.dataflow.dataflow_plan import (
DataflowPlanNode,
DataflowPlanNodeVisitor,
)
from metricflow.sql.sql_table import SqlTable


@dataclass(frozen=True)
Expand Down
4 changes: 2 additions & 2 deletions metricflow/dataset/convert_semantic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@
from metricflow_semantics.specs.dimension_spec import DimensionSpec
from metricflow_semantics.specs.entity_spec import EntitySpec
from metricflow_semantics.specs.time_dimension_spec import DEFAULT_TIME_GRANULARITY, TimeDimensionSpec
from metricflow_semantics.sql.sql_table import SqlTable
from metricflow_semantics.time.time_spine_source import TIME_SPINE_DATA_SET_DESCRIPTION, TimeSpineSource

from metricflow.dataset.semantic_model_adapter import SemanticModelDataSet
from metricflow.dataset.sql_dataset import SqlDataSet
from metricflow.plan_conversion.time_spine import TIME_SPINE_DATA_SET_DESCRIPTION, TimeSpineSource
from metricflow.sql.sql_exprs import (
SqlColumnReference,
SqlColumnReferenceExpression,
Expand All @@ -49,7 +50,6 @@
SqlSelectStatementNode,
SqlTableFromClauseNode,
)
from metricflow.sql.sql_table import SqlTable

logger = logging.getLogger(__name__)

Expand Down
8 changes: 3 additions & 5 deletions metricflow/engine/metricflow_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
from metricflow_semantics.mf_logging.pretty_print import mf_pformat
from metricflow_semantics.model.linkable_element_property import LinkableElementProperty
from metricflow_semantics.model.semantic_manifest_lookup import SemanticManifestLookup
from metricflow_semantics.model.semantics.linkable_element import (
LinkableDimension,
)
from metricflow_semantics.model.semantics.linkable_element import LinkableDimension
from metricflow_semantics.model.semantics.semantic_model_lookup import SemanticModelLookup
from metricflow_semantics.naming.linkable_spec_name import StructuredLinkableSpecName
from metricflow_semantics.protocols.query_parameter import GroupByParameter, MetricQueryParameter, OrderByQueryParameter
Expand All @@ -32,7 +30,9 @@
from metricflow_semantics.specs.query_param_implementations import SavedQueryParameter
from metricflow_semantics.specs.query_spec import MetricFlowQuerySpec
from metricflow_semantics.specs.spec_set import InstanceSpecSet
from metricflow_semantics.sql.sql_table import SqlTable
from metricflow_semantics.time.time_source import TimeSource
from metricflow_semantics.time.time_spine_source import TimeSpineSource

from metricflow.data_table.mf_table import MetricFlowDataTable
from metricflow.dataflow.builder.dataflow_plan_builder import DataflowPlanBuilder
Expand All @@ -52,10 +52,8 @@
from metricflow.execution.execution_plan import ExecutionPlan, SqlQuery
from metricflow.execution.executor import SequentialPlanExecutor
from metricflow.plan_conversion.dataflow_to_sql import DataflowToSqlQueryPlanConverter
from metricflow.plan_conversion.time_spine import TimeSpineSource
from metricflow.protocols.sql_client import SqlClient
from metricflow.sql.optimizer.optimization_levels import SqlQueryOptimizationLevel
from metricflow.sql.sql_table import SqlTable
from metricflow.telemetry.models import TelemetryLevel
from metricflow.telemetry.reporter import TelemetryReporter, log_call

Expand Down
2 changes: 1 addition & 1 deletion metricflow/execution/execution_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
from metricflow_semantics.dag.id_prefix import IdPrefix, StaticIdPrefix
from metricflow_semantics.dag.mf_dag import DagId, DagNode, DisplayedProperty, MetricFlowDag, NodeId
from metricflow_semantics.sql.sql_bind_parameters import SqlBindParameters
from metricflow_semantics.sql.sql_table import SqlTable
from metricflow_semantics.visitor import Visitable

from metricflow.data_table.mf_table import MetricFlowDataTable
from metricflow.protocols.sql_client import SqlClient
from metricflow.sql.sql_table import SqlTable

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion metricflow/plan_conversion/dataflow_to_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from metricflow_semantics.specs.time_dimension_spec import TimeDimensionSpec
from metricflow_semantics.sql.sql_join_type import SqlJoinType
from metricflow_semantics.time.time_constants import ISO8601_PYTHON_FORMAT
from metricflow_semantics.time.time_spine_source import TIME_SPINE_DATA_SET_DESCRIPTION, TimeSpineSource

from metricflow.dataflow.dataflow_plan import (
DataflowPlanNode,
Expand Down Expand Up @@ -101,7 +102,6 @@
ColumnEqualityDescription,
SqlQueryPlanJoinBuilder,
)
from metricflow.plan_conversion.time_spine import TIME_SPINE_DATA_SET_DESCRIPTION, TimeSpineSource
from metricflow.protocols.sql_client import SqlEngine
from metricflow.sql.optimizer.optimization_levels import (
SqlQueryOptimizationLevel,
Expand Down
2 changes: 1 addition & 1 deletion metricflow/sql/sql_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from dataclasses import dataclass
from typing import Optional

from metricflow.sql.sql_table import SqlTable
from metricflow_semantics.sql.sql_table import SqlTable


@dataclass(frozen=True, order=True)
Expand Down
2 changes: 1 addition & 1 deletion metricflow/sql/sql_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
from metricflow_semantics.dag.id_prefix import IdPrefix, StaticIdPrefix
from metricflow_semantics.dag.mf_dag import DagId, DagNode, DisplayedProperty, MetricFlowDag
from metricflow_semantics.sql.sql_join_type import SqlJoinType
from metricflow_semantics.sql.sql_table import SqlTable
from metricflow_semantics.visitor import VisitorOutputT
from typing_extensions import override

from metricflow.sql.sql_exprs import SqlExpressionNode
from metricflow.sql.sql_table import SqlTable

logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions tests_metricflow/dataflow/builder/test_node_data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
from metricflow_semantics.specs.entity_spec import LinklessEntitySpec
from metricflow_semantics.specs.measure_spec import MeasureSpec
from metricflow_semantics.sql.sql_join_type import SqlJoinType
from metricflow_semantics.sql.sql_table import SqlTable
from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration
from metricflow_semantics.test_helpers.snapshot_helpers import assert_spec_set_snapshot_equal
from metricflow_semantics.time.time_spine_source import TimeSpineSource

from metricflow.dataflow.builder.node_data_set import DataflowPlanNodeOutputDataSetResolver
from metricflow.dataflow.nodes.join_to_base import JoinDescription, JoinOnEntitiesNode
from metricflow.dataflow.nodes.read_sql_source import ReadSqlSourceNode
from metricflow.dataset.sql_dataset import SqlDataSet
from metricflow.plan_conversion.time_spine import TimeSpineSource
from metricflow.sql.sql_exprs import SqlColumnReference, SqlColumnReferenceExpression
from metricflow.sql.sql_plan import (
SqlSelectColumn,
SqlSelectStatementNode,
SqlTableFromClauseNode,
)
from metricflow.sql.sql_table import SqlTable
from tests_metricflow.fixtures.manifest_fixtures import MetricFlowEngineTestFixture, SemanticManifestSetup

logger = logging.getLogger(__name__)
Expand Down
3 changes: 2 additions & 1 deletion tests_metricflow/dataflow/test_sql_column.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

from metricflow_semantics.sql.sql_table import SqlTable

from metricflow.sql.sql_column import SqlColumn
from metricflow.sql.sql_table import SqlTable


def test_sql_column() -> None: # noqa: D103
Expand Down
3 changes: 1 addition & 2 deletions tests_metricflow/dataflow/test_sql_table.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import annotations

import pytest

from metricflow.sql.sql_table import SqlTable
from metricflow_semantics.sql.sql_table import SqlTable


def test_sql_table() -> None: # noqa: D103
Expand Down
2 changes: 1 addition & 1 deletion tests_metricflow/execution/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from metricflow_semantics.dag.mf_dag import DagId
from metricflow_semantics.random_id import random_id
from metricflow_semantics.sql.sql_bind_parameters import SqlBindParameters
from metricflow_semantics.sql.sql_table import SqlTable
from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration

from metricflow.data_table.mf_table import MetricFlowDataTable
Expand All @@ -14,7 +15,6 @@
)
from metricflow.execution.executor import SequentialPlanExecutor
from metricflow.protocols.sql_client import SqlClient, SqlEngine
from metricflow.sql.sql_table import SqlTable
from tests_metricflow.sql.compare_data_table import assert_data_tables_equal


Expand Down
2 changes: 1 addition & 1 deletion tests_metricflow/fixtures/dataflow_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from metricflow_semantics.query.query_parser import MetricFlowQueryParser
from metricflow_semantics.specs.column_assoc import ColumnAssociationResolver
from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration
from metricflow_semantics.time.time_spine_source import TimeSpineSource

from metricflow.dataflow.builder.dataflow_plan_builder import DataflowPlanBuilder
from metricflow.plan_conversion.time_spine import TimeSpineSource
from metricflow.protocols.sql_client import SqlClient
from tests_metricflow.fixtures.manifest_fixtures import MetricFlowEngineTestFixture, SemanticManifestSetup
from tests_metricflow.fixtures.sql_client_fixtures import sql_client # noqa: F401, F403
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
import time
from typing import Optional

from metricflow_semantics.sql.sql_table import SqlTable

from dbt_metricflow.cli.dbt_connectors.adapter_backed_client import AdapterBackedSqlClient
from metricflow.data_table.mf_column import ColumnDescription
from metricflow.data_table.mf_table import MetricFlowDataTable
from metricflow.protocols.sql_client import SqlEngine
from metricflow.sql.sql_table import SqlTable

logger = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion tests_metricflow/fixtures/sql_clients/ddl_sql_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from abc import abstractmethod
from typing import Optional, Protocol

from metricflow_semantics.sql.sql_table import SqlTable

from metricflow.data_table.mf_table import MetricFlowDataTable
from metricflow.protocols.sql_client import SqlClient
from metricflow.sql.sql_table import SqlTable


class SqlClientWithDDLMethods(SqlClient, Protocol):
Expand Down
2 changes: 1 addition & 1 deletion tests_metricflow/fixtures/table_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from dbt_semantic_interfaces.type_enums import TimeGranularity
from metricflow_semantics.model.semantic_manifest_lookup import SemanticManifestLookup
from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration
from metricflow_semantics.time.time_spine_source import TimeSpineSource

from metricflow.plan_conversion.time_spine import TimeSpineSource
from tests_metricflow.fixtures.sql_clients.ddl_sql_client import SqlClientWithDDLMethods
from tests_metricflow.source_schema_tools import create_tables_listed_in_table_snapshot_repository
from tests_metricflow.table_snapshot.table_snapshots import (
Expand Down
2 changes: 1 addition & 1 deletion tests_metricflow/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from metricflow_semantics.specs.dunder_column_association_resolver import DunderColumnAssociationResolver
from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration
from metricflow_semantics.test_helpers.time_helpers import ConfigurableTimeSource
from metricflow_semantics.time.time_spine_source import TimeSpineSource

from metricflow.engine.metricflow_engine import MetricFlowEngine
from metricflow.plan_conversion.time_spine import TimeSpineSource
from metricflow.protocols.sql_client import SqlClient


Expand Down
2 changes: 1 addition & 1 deletion tests_metricflow/integration/test_configured_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
from metricflow_semantics.protocols.query_parameter import DimensionOrEntityQueryParameter
from metricflow_semantics.specs.query_param_implementations import DimensionOrEntityParameter, TimeDimensionParameter
from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration
from metricflow_semantics.time.time_spine_source import TimeSpineSource

from metricflow.engine.metricflow_engine import MetricFlowQueryRequest
from metricflow.plan_conversion.time_spine import TimeSpineSource
from metricflow.protocols.sql_client import SqlClient
from metricflow.sql.sql_exprs import (
SqlCastToTimestampExpression,
Expand Down
2 changes: 1 addition & 1 deletion tests_metricflow/mf_logging/test_dag_to_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from metricflow_semantics.dag.dag_to_text import MetricFlowDagTextFormatter
from metricflow_semantics.dag.mf_dag import DagId
from metricflow_semantics.mf_logging.formatting import indent
from metricflow_semantics.sql.sql_table import SqlTable

from metricflow.sql.sql_exprs import (
SqlStringExpression,
Expand All @@ -19,7 +20,6 @@
SqlSelectStatementNode,
SqlTableFromClauseNode,
)
from metricflow.sql.sql_table import SqlTable

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion tests_metricflow/plan_conversion/test_time_spine.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from dbt_semantic_interfaces.type_enums import TimeGranularity
from metricflow_semantics.filters.time_constraint import TimeRangeConstraint
from metricflow_semantics.model.semantic_manifest_lookup import SemanticManifestLookup
from metricflow_semantics.time.time_spine_source import TimeSpineSource

from metricflow.plan_conversion.time_spine import TimeSpineSource
from metricflow.protocols.sql_client import SqlClient


Expand Down
2 changes: 1 addition & 1 deletion tests_metricflow/sql/optimizer/test_column_pruner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest
from _pytest.fixtures import FixtureRequest
from metricflow_semantics.sql.sql_join_type import SqlJoinType
from metricflow_semantics.sql.sql_table import SqlTable
from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration

from metricflow.sql.optimizer.column_pruner import SqlColumnPrunerOptimizer
Expand All @@ -22,7 +23,6 @@
SqlSelectStatementNode,
SqlTableFromClauseNode,
)
from metricflow.sql.sql_table import SqlTable
from tests_metricflow.sql.compare_sql_plan import assert_default_rendered_sql_equal


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest
from _pytest.fixtures import FixtureRequest
from metricflow_semantics.sql.sql_join_type import SqlJoinType
from metricflow_semantics.sql.sql_table import SqlTable
from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration

from metricflow.sql.optimizer.rewriting_sub_query_reducer import SqlRewritingSubQueryReducer
Expand All @@ -23,7 +24,6 @@
SqlSelectStatementNode,
SqlTableFromClauseNode,
)
from metricflow.sql.sql_table import SqlTable
from tests_metricflow.sql.compare_sql_plan import assert_default_rendered_sql_equal


Expand Down
2 changes: 1 addition & 1 deletion tests_metricflow/sql/optimizer/test_sub_query_reducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest
from _pytest.fixtures import FixtureRequest
from metricflow_semantics.sql.sql_join_type import SqlJoinType
from metricflow_semantics.sql.sql_table import SqlTable
from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration

from metricflow.sql.optimizer.sub_query_reducer import SqlSubQueryReducer
Expand All @@ -19,7 +20,6 @@
SqlSelectStatementNode,
SqlTableFromClauseNode,
)
from metricflow.sql.sql_table import SqlTable
from tests_metricflow.sql.compare_sql_plan import assert_default_rendered_sql_equal


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest
from _pytest.fixtures import FixtureRequest
from metricflow_semantics.sql.sql_join_type import SqlJoinType
from metricflow_semantics.sql.sql_table import SqlTable
from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration

from metricflow.sql.optimizer.table_alias_simplifier import SqlTableAliasSimplifier
Expand All @@ -19,7 +20,6 @@
SqlSelectStatementNode,
SqlTableFromClauseNode,
)
from metricflow.sql.sql_table import SqlTable
from tests_metricflow.sql.compare_sql_plan import assert_default_rendered_sql_equal


Expand Down
Loading

0 comments on commit 6a9ff9c

Please sign in to comment.