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

Use Time Spine description that aligns with other ReadSqlSourceNodes #1546

Merged
merged 1 commit into from
Dec 9, 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
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

logger = logging.getLogger(__name__)

TIME_SPINE_DATA_SET_DESCRIPTION = "Time Spine"


@dataclass(frozen=True)
class TimeSpineSource:
Expand Down Expand Up @@ -148,3 +146,8 @@ def choose_time_spine_sources(
required_time_spines.add(time_spine_sources[max(compatible_time_spines_for_standard_grains)])

return tuple(required_time_spines)

@property
def data_set_description(self) -> str:
"""Description to be displayed when this time spine is used in a data set."""
return f"Read From Time Spine '{self.table_name}'"
4 changes: 2 additions & 2 deletions metricflow/dataset/convert_semantic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from metricflow_semantics.specs.time_dimension_spec import DEFAULT_TIME_GRANULARITY, TimeDimensionSpec
from metricflow_semantics.sql.sql_table import SqlTable
from metricflow_semantics.time.granularity import ExpandedTimeGranularity
from metricflow_semantics.time.time_spine_source import TIME_SPINE_DATA_SET_DESCRIPTION, TimeSpineSource
from metricflow_semantics.time.time_spine_source import TimeSpineSource

from metricflow.dataset.semantic_model_adapter import SemanticModelDataSet
from metricflow.dataset.sql_dataset import SqlDataSet
Expand Down Expand Up @@ -568,7 +568,7 @@ def build_time_spine_source_data_set(self, time_spine_source: TimeSpineSource) -
return SqlDataSet(
instance_set=InstanceSet(time_dimension_instances=tuple(time_dimension_instances)),
sql_select_node=SqlSelectStatementNode.create(
description=TIME_SPINE_DATA_SET_DESCRIPTION,
description=time_spine_source.data_set_description,
select_columns=tuple(select_columns),
from_source=SqlTableNode.create(sql_table=time_spine_source.spine_table),
from_source_alias=from_source_alias,
Expand Down
4 changes: 2 additions & 2 deletions metricflow/plan_conversion/dataflow_to_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from metricflow_semantics.sql.sql_table import SqlTable
from metricflow_semantics.time.granularity import ExpandedTimeGranularity
from metricflow_semantics.time.time_constants import ISO8601_PYTHON_FORMAT, ISO8601_PYTHON_TS_FORMAT
from metricflow_semantics.time.time_spine_source import TIME_SPINE_DATA_SET_DESCRIPTION, TimeSpineSource
from metricflow_semantics.time.time_spine_source import TimeSpineSource
from typing_extensions import override

from metricflow.dataflow.dataflow_plan import (
Expand Down Expand Up @@ -400,7 +400,7 @@ def _make_time_spine_data_set(
)

inner_sql_select_node = SqlSelectStatementNode.create(
description=TIME_SPINE_DATA_SET_DESCRIPTION,
description=time_spine_source.data_set_description,
select_columns=select_columns,
from_source=SqlTableNode.create(sql_table=time_spine_source.spine_table),
from_source_alias=time_spine_table_alias,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FROM (
subq_4.metric_time__day AS metric_time__day
, subq_3.visits AS visits
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_5.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_5
Expand Down Expand Up @@ -128,7 +128,7 @@ FROM (
subq_17.metric_time__day AS metric_time__day
, subq_16.buys AS buys
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_18.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FROM (
subq_4.metric_time__day AS metric_time__day
, subq_3.visits AS visits
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_5.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_5
Expand Down Expand Up @@ -128,7 +128,7 @@ FROM (
subq_17.metric_time__day AS metric_time__day
, subq_16.buys AS buys
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_18.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FROM (
subq_4.metric_time__day AS metric_time__day
, subq_3.visits AS visits
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_5.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_5
Expand Down Expand Up @@ -128,7 +128,7 @@ FROM (
subq_17.metric_time__day AS metric_time__day
, subq_16.buys AS buys
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_18.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FROM (
subq_4.metric_time__day AS metric_time__day
, subq_3.visits AS visits
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_5.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_5
Expand Down Expand Up @@ -128,7 +128,7 @@ FROM (
subq_17.metric_time__day AS metric_time__day
, subq_16.buys AS buys
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_18.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FROM (
subq_4.metric_time__day AS metric_time__day
, subq_3.visits AS visits
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_5.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_5
Expand Down Expand Up @@ -128,7 +128,7 @@ FROM (
subq_17.metric_time__day AS metric_time__day
, subq_16.buys AS buys
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_18.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FROM (
subq_4.metric_time__day AS metric_time__day
, subq_3.visits AS visits
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_5.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_5
Expand Down Expand Up @@ -128,7 +128,7 @@ FROM (
subq_17.metric_time__day AS metric_time__day
, subq_16.buys AS buys
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_18.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FROM (
subq_4.metric_time__day AS metric_time__day
, subq_3.visits AS visits
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_5.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_5
Expand Down Expand Up @@ -128,7 +128,7 @@ FROM (
subq_17.metric_time__day AS metric_time__day
, subq_16.buys AS buys
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_18.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ docstring:
<!-- where = None -->
<!-- distinct = False -->
<SqlSelectStatementNode>
<!-- description = 'Time Spine' -->
<!-- description = "Read From Time Spine 'mf_time_spine'" -->
<!-- node_id = NodeId(id_str='ss_4') -->
<!-- col0 = -->
<!-- SqlSelectColumn( -->
Expand Down Expand Up @@ -504,7 +504,7 @@ docstring:
<!-- where = None -->
<!-- distinct = False -->
<SqlSelectStatementNode>
<!-- description = 'Time Spine' -->
<!-- description = "Read From Time Spine 'mf_time_spine'" -->
<!-- node_id = NodeId(id_str='ss_16') -->
<!-- col0 = -->
<!-- SqlSelectColumn( -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ FROM (
, subq_1.revenue_instance__user AS revenue_instance__user
, subq_1.txn_revenue AS txn_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_3.ds AS metric_time__day
, DATETIME_TRUNC(subq_3.ds, isoweek) AS metric_time__week
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ FROM (
, subq_2.revenue_instance__user AS revenue_instance__user
, subq_2.txn_revenue AS txn_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_4.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SELECT
subq_12.metric_time__day AS metric_time__day
, SUM(subq_11.txn_revenue) AS revenue_all_time
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
ds AS metric_time__day
FROM ***************************.mf_time_spine subq_13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ FROM (
, subq_1.revenue_instance__user AS revenue_instance__user
, subq_1.txn_revenue AS txn_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
DATETIME_TRUNC(subq_3.ds, month) AS revenue_instance__ds__month
, subq_3.ds AS metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ FROM (
, subq_1.revenue_instance__user AS revenue_instance__user
, subq_1.txn_revenue AS txn_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_3.ds AS revenue_instance__ds__day
FROM ***************************.mf_time_spine subq_3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ FROM (
, subq_1.revenue_instance__user AS revenue_instance__user
, subq_1.txn_revenue AS txn_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_3.ds AS revenue_instance__ds__day
, DATETIME_TRUNC(subq_3.ds, month) AS revenue_instance__ds__month
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ FROM (
, subq_1.revenue_instance__user AS revenue_instance__user
, subq_1.txn_revenue AS txn_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_3.ds AS metric_time__day
, DATETIME_TRUNC(subq_3.ds, month) AS metric_time__month
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ FROM (
, subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99
, subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_3.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ FROM (
, subq_1.revenue_instance__user AS revenue_instance__user
, subq_1.txn_revenue AS txn_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_3.ds AS metric_time__day
, DATETIME_TRUNC(subq_3.ds, isoweek) AS metric_time__week
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ FROM (
, subq_2.revenue_instance__user AS revenue_instance__user
, subq_2.txn_revenue AS txn_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_4.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SELECT
subq_12.metric_time__day AS metric_time__day
, SUM(subq_11.txn_revenue) AS trailing_2_months_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
ds AS metric_time__day
FROM ***************************.mf_time_spine subq_13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ FROM (
, subq_1.revenue_instance__user AS revenue_instance__user
, subq_1.txn_revenue AS txn_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_3.ds AS metric_time__day
, DATETIME_TRUNC(subq_3.ds, isoweek) AS metric_time__week
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ FROM (
, subq_1.revenue_instance__user AS revenue_instance__user
, subq_1.txn_revenue AS txn_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_3.ds AS metric_time__day
, DATETIME_TRUNC(subq_3.ds, month) AS metric_time__month
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ FROM (
, subq_1.revenue_instance__user AS revenue_instance__user
, subq_1.txn_revenue AS txn_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
DATETIME_TRUNC(subq_3.ds, quarter) AS revenue_instance__ds__quarter
, DATETIME_TRUNC(subq_3.ds, year) AS revenue_instance__ds__year
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ FROM (
, subq_1.revenue_instance__user AS revenue_instance__user
, subq_1.txn_revenue AS txn_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_3.ds AS metric_time__day
, DATETIME_TRUNC(subq_3.ds, year) AS metric_time__year
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ FROM (
, subq_7.metric_time__week AS metric_time__week
, subq_6.bookers AS bookers
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
DATETIME_TRUNC(subq_8.ds, month) AS booking__ds__month
, subq_8.ds AS metric_time__day
Expand Down Expand Up @@ -161,7 +161,7 @@ FROM (
, subq_1.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99
, subq_1.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
DATETIME_TRUNC(subq_3.ds, month) AS booking__ds__month
, subq_3.ds AS metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ FROM (
, subq_1.revenue_instance__user AS revenue_instance__user
, subq_1.txn_revenue AS txn_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_3.ds AS metric_time__day
, DATE_TRUNC('week', subq_3.ds) AS metric_time__week
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ FROM (
, subq_2.revenue_instance__user AS revenue_instance__user
, subq_2.txn_revenue AS txn_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_4.ds AS metric_time__day
FROM ***************************.mf_time_spine subq_4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SELECT
subq_12.metric_time__day AS metric_time__day
, SUM(subq_11.txn_revenue) AS revenue_all_time
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
ds AS metric_time__day
FROM ***************************.mf_time_spine subq_13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ FROM (
, subq_1.revenue_instance__user AS revenue_instance__user
, subq_1.txn_revenue AS txn_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
DATE_TRUNC('month', subq_3.ds) AS revenue_instance__ds__month
, subq_3.ds AS metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ FROM (
, subq_1.revenue_instance__user AS revenue_instance__user
, subq_1.txn_revenue AS txn_revenue
FROM (
-- Time Spine
-- Read From Time Spine 'mf_time_spine'
SELECT
subq_3.ds AS revenue_instance__ds__day
FROM ***************************.mf_time_spine subq_3
Expand Down
Loading
Loading