version: 1.0.0
dataset: gold_headcount

info:
  title: Headcount by Department (Gold)
  version: 1.0.0
  table_name: "{gold_layer}_headcount"
  description: >
    Department-level headcount summary. Filters to active employees
    and enriches with salary band for executive dashboards.
  target_layer: gold
  domain: hr
  system: employees

primary_key:
  - id

model:
  fields:
    - name: id
      type: integer
      required: true
    - name: name
      type: string
    - name: email
      type: string
    - name: department
      type: string
      required: true
    - name: salary
      type: integer
    - name: hire_date
      type: string
    - name: status
      type: string
    - name: salary_band
      type: string
      description: "Derived: Junior / Mid / Senior / Executive"

source:
  type: landing
  path: "output/silver_employees/data.parquet"
  format: parquet

transformations:
  # Only active employees
  - phase: pre
    filter: "status = 'active'"

  # Derive salary band
  - phase: pre
    derive:
      field: salary_band
      sql: >
        CASE
          WHEN salary < 70000 THEN 'Junior'
          WHEN salary < 90000 THEN 'Mid'
          WHEN salary < 120000 THEN 'Senior'
          ELSE 'Executive'
        END

quality:
  row_rules:
    - name: valid_salary
      sql: "salary > 0"
      category: validity
    - name: valid_department
      sql: "department IS NOT NULL"
      category: completeness

materialization:
  target_path: "output/gold_headcount"
  strategy: overwrite
  format: parquet
