class_docstr: Generates an SQL query plan from a node in the a metric dataflow plan.
class_docstr_tok: ["Generates","an","SQL","query","plan","from","a","node","in","the","a","metric","dataflow","plan","."]
docstr: Make a time spine data set, which contains all date values like '2020-01-01', '2020-01-02'...
  
  This is useful in computing cumulative metrics. This will need to be updated to support granularities finer than a
  day.
docstr_tok: ["Make","a","time","spine","data","set",",","which","contains","all","date","values","like","'2020-01-01","'",",","'2020-01-02","'","...","This","is","useful","in","computing","cumulative","metrics",".","This","will","need","to","be","updated","to","support","granularities","finer","than","a","day","."]
code: def _make_time_spine_data_set(
      self,
      metric_time_dimension_instance: TimeDimensionInstance,
      metric_time_dimension_column_name: str,
      time_spine_source: TimeSpineSource,
      time_range_constraint: Optional[TimeRangeConstraint] = None,
  ) -> SqlDataSet:
      """Make a time spine data set, which contains all date values like '2020-01-01', '2020-01-02'...
  
      This is useful in computing cumulative metrics. This will need to be updated to support granularities finer than a
      day.
      """
      time_spine_instance = (
          TimeDimensionInstance(
              defined_from=metric_time_dimension_instance.defined_from,
              associated_columns=(
                  ColumnAssociation(
                      column_name=metric_time_dimension_column_name,
                      single_column_correlation_key=SingleColumnCorrelationKey(),
                  ),
              ),
              spec=metric_time_dimension_instance.spec,
          ),
      )
      time_spine_instance_set = InstanceSet(
          time_dimension_instances=time_spine_instance,
      )
      description = "Date Spine"
      time_spine_table_alias = self._next_unique_table_alias()
  
      # If the requested granularity is the same as the granularity of the spine, do a direct select.
      if (
          metric_time_dimension_instance.spec.time_granularity
          == time_spine_source.time_column_granularity
      ):
          return SqlDataSet(
              instance_set=time_spine_instance_set,
              sql_select_node=SqlSelectStatementNode(
                  description=description,
                  # This creates select expressions for all columns referenced in the instance set.
                  select_columns=(
                      SqlSelectColumn(
                          expr=SqlColumnReferenceExpression(
                              SqlColumnReference(
                                  table_alias=time_spine_table_alias,
                                  column_name=time_spine_source.time_column_name,
                              ),
                          ),
                          column_alias=metric_time_dimension_column_name,
                      ),
                  ),
                  from_source=SqlTableFromClauseNode(
                      sql_table=time_spine_source.spine_table
                  ),
                  from_source_alias=time_spine_table_alias,
                  joins_descs=(),
                  group_bys=(),
                  where=_make_time_range_comparison_expr(
                      table_alias=time_spine_table_alias,
                      column_alias=time_spine_source.time_column_name,
                      time_range_constraint=time_range_constraint,
                  )
                  if time_range_constraint
                  else None,
                  order_bys=(),
              ),
          )
      # If the granularity is different, apply a DATE_TRUNC() and aggregate.
      else:
          select_columns = (
              SqlSelectColumn(
                  expr=SqlDateTruncExpression(
                      time_granularity=metric_time_dimension_instance.spec.time_granularity,
                      arg=SqlColumnReferenceExpression(
                          SqlColumnReference(
                              table_alias=time_spine_table_alias,
                              column_name=time_spine_source.time_column_name,
                          ),
                      ),
                  ),
                  column_alias=metric_time_dimension_column_name,
              ),
          )
          return SqlDataSet(
              instance_set=time_spine_instance_set,
              sql_select_node=SqlSelectStatementNode(
                  description=description,
                  # This creates select expressions for all columns referenced in the instance set.
                  select_columns=select_columns,
                  from_source=SqlTableFromClauseNode(
                      sql_table=time_spine_source.spine_table
                  ),
                  from_source_alias=time_spine_table_alias,
                  joins_descs=(),
                  group_bys=select_columns,
                  where=_make_time_range_comparison_expr(
                      table_alias=time_spine_table_alias,
                      column_alias=time_spine_source.time_column_name,
                      time_range_constraint=time_range_constraint,
                  )
                  if time_range_constraint
                  else None,
                  order_bys=(),
              ),
          )
  
imports: from __future__ import annotations
  import logging
  from collections import OrderedDict
  from typing import List, Optional, Sequence, Tuple, Union
  from dbt_semantic_interfaces.enum_extension import assert_values_exhausted
  from dbt_semantic_interfaces.protocols.metric import MetricInputMeasure, MetricType
  from dbt_semantic_interfaces.references import MetricModelReference
  from dbt_semantic_interfaces.type_enums.aggregation_type import AggregationType
  from dbt_semantic_interfaces.type_enums.conversion_calculation_type import ConversionCalculationType
  from dbt_semantic_interfaces.validations.unique_valid_name import MetricFlowReservedKeywords
  from metricflow.aggregation_properties import AggregationState
  from metricflow.dag.id_generation import IdGeneratorRegistry
  from metricflow.dataflow.dataflow_plan import AddGeneratedUuidColumnNode, AggregateMeasuresNode, BaseOutput, CombineAggregatedOutputsNode, ComputedMetricsOutput, ComputeMetricsNode, ConstrainTimeRangeNode, DataflowPlanNodeVisitor, FilterElementsNode, JoinConversionEventsNode, JoinOverTimeRangeNode, JoinToBaseOutputNode, JoinToTimeSpineNode, MetricTimeDimensionTransformNode, MinMaxNode, OrderByLimitNode, ReadSqlSourceNode, SemiAdditiveJoinNode, WhereConstraintNode, WriteToResultDataframeNode, WriteToResultTableNode
  from metricflow.dataset.dataset import DataSet
  from metricflow.dataset.sql_dataset import SqlDataSet
  from metricflow.filters.time_constraint import TimeRangeConstraint
  from metricflow.instances import InstanceSet, MetadataInstance, MetricInstance, TimeDimensionInstance
  from metricflow.model.semantic_manifest_lookup import SemanticManifestLookup
  from metricflow.plan_conversion.instance_converters import AddLinkToLinkableElements, AddMetadata, AddMetrics, AliasAggregatedMeasures, ChangeAssociatedColumns, ChangeMeasureAggregationState, ConvertToMetadata, CreateSelectColumnForCombineOutputNode, CreateSelectColumnsForInstances, CreateSelectColumnsWithMeasuresAggregated, CreateSqlColumnReferencesForInstances, FilterElements, FilterLinkableInstancesWithLeadingLink, RemoveMeasures, RemoveMetrics, UpdateMeasureFillNullsWith, create_select_columns_for_instance_sets
  from metricflow.plan_conversion.select_column_gen import SelectColumnSet
  from metricflow.plan_conversion.spec_transforms import CreateColumnAssociations, CreateSelectCoalescedColumnsForLinkableSpecs, SelectOnlyLinkableSpecs
  from metricflow.plan_conversion.sql_join_builder import AnnotatedSqlDataSet, ColumnEqualityDescription, SqlQueryPlanJoinBuilder
  from metricflow.plan_conversion.time_spine import TimeSpineSource
  from metricflow.protocols.sql_client import SqlEngine
  from metricflow.specs.column_assoc import ColumnAssociation, ColumnAssociationResolver, SingleColumnCorrelationKey
  from metricflow.specs.specs import InstanceSpecSet, MeasureSpec, MetadataSpec, MetricSpec, TimeDimensionSpec
  from metricflow.sql.optimizer.optimization_levels import SqlQueryOptimizationLevel, SqlQueryOptimizerConfiguration
  from metricflow.sql.sql_exprs import SqlAggregateFunctionExpression, SqlBetweenExpression, SqlColumnReference, SqlColumnReferenceExpression, SqlComparison, SqlComparisonExpression, SqlDateTruncExpression, SqlExpressionNode, SqlExtractExpression, SqlFunction, SqlFunctionExpression, SqlGenerateUuidExpression, SqlLogicalExpression, SqlLogicalOperator, SqlRatioComputationExpression, SqlStringExpression, SqlStringLiteralExpression, SqlWindowFunction, SqlWindowFunctionExpression, SqlWindowOrderByArgument
  from metricflow.sql.sql_plan import SqlJoinDescription, SqlJoinType, SqlOrderByDescription, SqlQueryPlan, SqlQueryPlanNode, SqlSelectColumn, SqlSelectStatementNode, SqlTableFromClauseNode
  from metricflow.time.time_constants import ISO8601_PYTHON_FORMAT
label_desc: Use image node_id 4 for calling the DataflowToSqlQueryPlanConverter obj's underlying member method code with example usage: obj._make_time_spine_data_set(metric_time_dimension_instance, metric_time_dimension_column_name, time_spine_source, time_range_constraint) and returns: SqlDataSet, SqlDataSet