Principle:173TECH Sayn Column DDL Validation
| Knowledge Sources | |
|---|---|
| Domains | Data_Modelling, Validation |
| Last Updated | 2026-10-17 00:00 GMT |
Overview
Pattern for validating column definitions, table properties, and post-execution hooks through a pydantic schema that transforms raw YAML into a structured DDL representation.
Description
Column DDL validation ensures that column definitions specified in task YAML are valid before execution. The DDL pydantic model:
- Accepts columns as strings (auto-converted to
{"name": ...}) or mappings - Validates column uniqueness (no duplicate names)
- Supports column types, destination names (
dst_name), descriptions - Embeds test definitions within each column
- Validates
post_hookentries (each must have asqlfield)
The validated DDL is used by ETL operations (create table, replace table) and by the test system for constructing standard column test queries.
Usage
Use this principle when task configurations include column DDL that must be validated before generating SQL DDL statements. It is the right choice when you want type-safe, validated column definitions that catch errors early.
Theoretical Basis
The validation pipeline:
- Input normalization: String columns become
{"name": "column_name"} - Pydantic validation: Each column validated against
Columnsmodel withTestssub-model - Transformation: Validated columns transformed into DDL dict with
name,type,dst_name,tests - Test construction: Test strings become
{"type": "unique", "allowed_values": [], "execute": true}
The _format_properties method adds flags: unique, not_null, allowed_values based on test types.
Practical Guide
# Column DDL in task config
columns:
- user_id # String: auto-converted to {name: user_id}
- name: email
type: VARCHAR
dst_name: email_address
tests:
- not_null
- unique
- name: status
type: VARCHAR
tests:
- name: allowed_values
allowed_values: [active, inactive]
# Post-execution hooks
post_hook:
- sql: "CREATE INDEX idx_user_id ON {{ out('analytics.users') }} (user_id)"
# Table properties
table_properties:
distribution: user_id
sortkey: created_at