version: 1.0.0
dataset: employees_validated
info:
  title: XML Employee Data Validation
  version: 1.0.0
  description: 'Example contract demonstrating XML ingestion with LakeLogic.

    This ingests employee data from XML files, validates email formats,

    salary ranges, and employee status.

    '
source:
  type: landing
  path: data/employees.xml
model:
  fields:
  - name: id
    type: integer
    description: Employee ID
  - name: name
    type: string
    description: Employee full name
  - name: email
    type: string
    description: Employee email address
  - name: department
    type: string
    description: Department name
  - name: salary
    type: decimal
    description: Annual salary
  - name: hire_date
    type: date
    description: Date employee was hired
  - name: status
    type: string
    description: Employment status (active/inactive)
  - name: seniority_level
    type: string
    description: Derived seniority based on hire date
schema_policy:
  unknown_fields: quarantine
  missing_fields: fail
quality:
  row_rules:
  - name: Valid Email
    sql: email LIKE '%@%'
    category: correctness
  - name: Valid Salary
    sql: salary > 0
    category: correctness
  - name: Active Employees Only
    sql: status = 'active'
    category: business_rule
  dataset_rules:
  - name: Unique Employee IDs
    unique: id
  - name: Minimum Record Count
    row_count_between:
      min: 1
      max: 10000
transformations:
- trim:
    fields:
    - name
    - email
    - department
    - status
- lower:
    fields:
    - email
- derive:
    field: seniority_level
    sql: "CASE\n  WHEN hire_date <= CAST('2022-12-31' AS DATE) THEN 'senior'\n  WHEN hire_date <= CAST('2023-12-31' AS DATE) THEN 'mid'\n  ELSE 'junior'\nEND"
- select:
    columns:
    - id
    - name
    - email
    - department
    - salary
    - hire_date
    - status
    - seniority_level
quarantine:
  include_error_reason: true
  include_categories: true
