version: 1

# External-incremental GCS load (ADR 0018) for metadb.tenants — a sibling unit to metadb/
# (billing2_invoices) and metadb_users/. The load engine is one-table-per-source unit, so each
# metadb table that is its own bucket prefix gets its own unit; all write the shared metadb_raw db.
#
# NOTE: not consumed by salesforce_org_monthly_revrec — snapshotting cloud_tenants from BigQuery
# removed that dependency (ADR 0019). Kept for future models that need tenant attributes directly.
# The export prefix below is a placeholder: confirm the real gs:// path of the metadb tenants export.

load:
  name: metadb_tenants
  engine: databend
  secrets_file: secrets.env

cloud_lake:
  dsn_env: DATABEND_DSN
  databases:
    raw: metadb_raw

external:
  uri: gs://metadb/metadb/REPLACE-WITH-PREFIX/tenants/
  incremental:
    strategy: filename
    pattern: 'run-(?P<ts>\d+)-'
  delta: true
  table: tenants
  domain: identity
  owner: data-platform
  system: bigquery
  primary_key: [id]

gcs:
  credential_env: METADB_GCS_CREDENTIAL
  reader:
    project: gcp-digital-bi-dev

governance:
  classifications:
    - restricted
    - customer_data
  classification_patterns:
    customer_data: "email|name|company|country|tenant"
    operational_sensitive: "token|secret|password|credential"

setup:
  databend:
    files:
      # Shared with the other metadb units — all land in metadb_raw.
      - ingestion/load/gcs_bulk_load/setup/databend/metadb/001_databases.sql

# Externally-managed source: its `source` contract is provided (bootstrapped by inference via
# infer-source, committed under contracts/upstream/). The load owns only the raw-snapshot product
# contract it generates from that upstream (ADR 0015/0016).
source_contracts:
  - ref: ingestion/load/gcs_bulk_load/sources/metadb_tenants/contracts/upstream/*.external.source.contract.yaml
