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

    This shows how to flatten hierarchical XML structures and validate

    complex nested data like employee records with nested contact info,

    department details, and compensation structures.

    '
source:
  type: landing
  path: data/employees_nested.xml
model:
  fields:
  - name: id
    type: integer
    description: Employee ID
  - name: first_name
    type: string
    description: Employee first name
  - name: last_name
    type: string
    description: Employee last name
  - name: full_name
    type: string
    description: Derived full name
  - name: email
    type: string
    description: Employee email
  - name: phone
    type: string
    description: Phone number
  - name: department
    type: string
    description: Department name
  - name: location
    type: string
    description: Office location
  - name: salary
    type: decimal
    description: Annual salary
  - name: currency
    type: string
    description: Salary currency
  - name: bonus_eligible
    type: boolean
    description: Bonus eligibility
  - name: hire_date
    type: date
    description: Hire date
  - name: status
    type: string
    description: Employment status
  - name: seniority_level
    type: string
    description: Derived seniority
schema_policy:
  unknown_fields: drop
  missing_fields: fail
transformations:
- phase: pre
  rename:
    from:
    - personal_info_name_first
    - first
    to:
    - first_name
    - first_name
- phase: pre
  rename:
    from:
    - personal_info_name_last
    - last
    to:
    - last_name
    - last_name
- phase: pre
  rename:
    from:
    - personal_info_contact_email
    - email
    to:
    - email
    - email
- phase: pre
  rename:
    from:
    - personal_info_contact_phone
    - phone
    to:
    - phone
    - phone
- phase: pre
  rename:
    from:
    - employment_department_name
    - department_name
    to:
    - department
    - department
- phase: pre
  rename:
    from:
    - employment_department_location
    - location
    to:
    - location
    - location
- phase: pre
  rename:
    from:
    - employment_compensation_salary
    - salary
    to:
    - salary
    - salary
- phase: pre
  rename:
    from:
    - employment_compensation_salary_currency
    - currency
    to:
    - currency
    - currency
- phase: pre
  rename:
    from:
    - employment_compensation_bonus_eligible
    - bonus_eligible
    to:
    - bonus_eligible
    - bonus_eligible
- phase: pre
  rename:
    from:
    - employment_dates_hire_date
    - hire_date
    to:
    - hire_date
    - hire_date
- phase: pre
  rename:
    from:
    - employment_status
    - status
    to:
    - status
    - status
- trim:
    fields:
    - first_name
    - last_name
    - email
    - department
    - location
    - status
- lower:
    fields:
    - email
- derive:
    field: full_name
    sql: first_name || ' ' || last_name
- 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
    - first_name
    - last_name
    - full_name
    - email
    - phone
    - department
    - location
    - salary
    - currency
    - bonus_eligible
    - hire_date
    - status
    - seniority_level
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
quarantine:
  include_error_reason: true
  include_categories: true
