Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:173TECH Sayn Column DDL Validation

From Leeroopedia
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_hook entries (each must have a sql field)

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:

  1. Input normalization: String columns become {"name": "column_name"}
  2. Pydantic validation: Each column validated against Columns model with Tests sub-model
  3. Transformation: Validated columns transformed into DDL dict with name, type, dst_name, tests
  4. 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

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment