Schedule icon
Query icon
Script icon
If icon
Log icon
OutputValues icon
Fail icon

Dataset Schema Evolution & Compatibility Gate

Validate CSV schema changes against a contract and block downstream processing when breaking changes are detected.

Categories
CoreData

Validate an incoming CSV dataset against an expected schema contract before allowing downstream processing.

The workflow detects structural changes in an incoming dataset by comparing its detected schema with a predefined schema contract.

How it works

  1. Accept an expected schema contract as JSON.
  2. Accept an incoming CSV dataset.
  3. Use DuckDB to detect the incoming column names and data types.
  4. Normalize database types into contract-level types.
  5. Compare the detected schema with the expected schema.
  6. Identify added, removed, and type-changed columns.
  7. Generate a structured compatibility audit.
  8. Continue when the schema is compatible.
  9. Stop the workflow when breaking changes are detected.

Compatibility rules

  • Existing columns with matching types are compatible.
  • Added columns are compatible.
  • Removed expected columns are breaking changes.
  • Changed column types are breaking changes.
  • Column order changes are compatible because columns are compared by name.

Prerequisites

  • A running Kestra instance.
  • DuckDB plugin available.
  • A CSV dataset.
  • An expected schema contract.

Secrets

This workflow does not require secrets.

Outputs

The comparison task exposes:

  • outputs.compare_schemas.vars.compatible
  • outputs.compare_schemas.vars.added_columns
  • outputs.compare_schemas.vars.removed_columns
  • outputs.compare_schemas.vars.type_changes
  • outputs.compare_schemas.vars.breaking_changes

Important considerations

CSV schema inference depends on the actual values present in the dataset. Requiredness is therefore defined by the expected schema contract rather than inferred from the CSV.

A renamed column is treated as a removed column plus an added column.

Quick start

  1. Add the flow to Kestra.
  2. Provide an expected schema contract.
  3. Provide the incoming CSV data.
  4. Execute the flow.
  5. Review the schema comparison and compatibility decision.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.