Skip to content

derived

sqllocks_spindle.engine.strategies.derived

Derived strategy — compute a column's values from another column.

Supports two modes:

  1. Same-table: derive from another column already generated in this table. Example: end_date = start_date + uniform(3, 30) days

  2. Cross-table via FK: derive from a column in a parent table, joined via a FK column already generated in this table. Example: return_date = order.order_date + log_normal(mean=2, sigma=0.8) days

Schema examples:

# Same-table: end_date from start_date
"end_date": {
    "generator": {
        "strategy": "derived",
        "source": "start_date",
        "rule": "add_days",
        "params": {"distribution": "uniform", "min": 3, "max": 30}
    }
}

# Cross-table: return_date from order.order_date via order_id
"return_date": {
    "generator": {
        "strategy": "derived",
        "source": "order.order_date",
        "via": "order_id",
        "rule": "add_days",
        "params": {"distribution": "log_normal", "mean": 2.0, "sigma": 0.8, "min": 1, "max": 90}
    }
}
Supported rules
  • add_days: add a random number of days drawn from the given distribution
  • copy: copy the source value unchanged

Classes

DerivedStrategy

Bases: Strategy

Derive a column's values from another column with an optional transformation.