# --- Gateway Connection ---
# Single local DuckDB gateway
# Local dev uses virtual environments (e.g., dev_<username>)
# Production uses the 'prod' environment
gateways:
  duckdb:
    connection:
      type: duckdb
      catalogs:
        local: '{{ env_var("DUCKDB_PATH", "local.duckdb") }}'

default_gateway: duckdb

# --- Variables ---
variables:
  LANDING_DIR: '{{ env_var("LANDING_DIR", "data/landing") }}'

# --- Model Defaults ---
# https://sqlmesh.readthedocs.io/en/stable/reference/model_configuration/#model-defaults

model_defaults:
  dialect: duckdb
  start: 2025-07-07 # Start date for backfill history
  cron: '@daily'    # Run models daily at 12am UTC (can override per model)

# --- Linting Rules ---
# https://sqlmesh.readthedocs.io/en/stable/guides/linter/

linter:
  enabled: true
  rules:
    # ambiguousorinvalidcolumn removed: sqlglot cannot introspect read_csv() TVF
    # schemas at lint time, causing false positives on all raw models. Cross-model
    # column validation is handled by SQLMesh at plan time via columns() declarations.
    - invalidselectstarexpansion

# --- Default Target Environment ---
# Prevents accidentally applying plans to prod during local development.
# https://sqlmesh.readthedocs.io/en/stable/guides/configuration/#default-target-environment

default_target_environment: dev_{{ user() }}
