# Sample MetricFlow-style semantic definition (illustrative, CC BY 4.0)
# Protocol: https://infinisynapse.com/en/blog/dbt-semantic-layer#yaml-example-pilot-metric
# Not a substitute for current dbt Labs YAML schema — verify against docs.getdbt.com

semantic_models:
  - name: subscriptions_revenue
    model: ref('fct_subscriptions')
    description: "Monthly recurring revenue grain: one row per subscription per month."
    defaults:
      agg_time_dimension: month
    entities:
      - name: subscription
        type: primary
        expr: subscription_id
      - name: account
        type: foreign
        expr: account_id
    dimensions:
      - name: month
        type: time
        type_params:
          time_granularity: month
        expr: month_start
      - name: plan_tier
        type: categorical
        expr: plan_tier
    measures:
      - name: mrr_amount
        agg: sum
        expr: mrr_usd
        create_metric: true

metrics:
  - name: monthly_recurring_revenue
    description: "Sum of MRR in USD at subscription-month grain."
    type: simple
    type_params:
      measure: mrr_amount
