Transformers & pipeline¶
TL;DR TransformerPipeline runs a fixed ordered list of transformers
between read and write. Each transformer has an order integer (lower first);
DataCoolie's twelve built-ins claim the slots 5 / 10 / 18 / 20 / 30 / 35 / 60 / 70 / 80 / 84 / 85 / 90,
leaving 40–50 free for user plugins.
The twelve built-ins (order → responsibility)¶
| Order | Name | Responsibility |
|---|---|---|
| 5 | ColumnValueTransformer |
Apply typed value rules in stable (order, declaration) order before schema casting. |
| 10 | SchemaConverter |
Cast columns to schema_hints types after value normalization — downstream typed transforms see the target schema. |
| 18 | HashColumnAdder |
Add stable SHA-256 String or signed XXHash64 BIGINT values from typed canonical payloads. |
| 20 | Deduplicator |
Drop duplicates by transform.deduplicate_columns (partition keys) and dataflow.order_columns (latest-row selector, from transform.latest_data_columns or source.watermark_columns). Value normalization, schema casting and hash creation run first; deduplication reduces rows for subsequent transforms. |
| 30 | ColumnAdder |
User-configured calculated columns from transform.additional_columns. |
| 35 | RowFilter |
Discard rows by transform.filter_expression after computed columns exist but before SCD2 logic. |
| 60 | SCD2ColumnAdder |
For load_type="scd2" only: copy scd2_effective_column into __valid_from, seed __valid_to = NULL, __is_current = true. No-op otherwise. |
| 70 | SystemColumnAdder |
Framework audit columns: __created_at, __updated_at, __updated_by, and driver-managed __dataflow_run_id. |
| 80 | PartitionHandler |
Derive partition values from SQL expressions. |
| 84 | DataMasker |
Mask structured scalar PII after business transforms and before projection. |
| 85 | ColumnProjector |
Resolve select/drop against source names, then apply atomic renames. |
| 90 | ColumnNameSanitizer |
Last — sanitise casing and special chars for the destination engine. |
DataCoolieDriver assembles these built-ins; TransformerPipeline sorts by
each transformer's order attribute. Use the
transform recipes for metadata
configuration and examples rather than copying the default list into a runner.
Empty-result boundary¶
The orchestration layer uses the typed source result's frame and
rows_read as the source-stage gate. When the frame is None or
rows_read == 0, it skips transformation, writing, and watermark saving,
including for a bounded replay. There is no second row-count or empty-result
gate after transformation: a transform that removes every row is passed to
the writer, and a replacement writer may delete the selected scope. Put
predicates on source-result columns in source.filter_expression when an
earlier read-stage filter is appropriate; reader pushdown is not automatic.
HashColumnAdder hashes only the explicitly declared ordered input columns. A
hash target does not automatically become a merge or deduplication key, and
hash inputs do not silently fall back to transform.deduplicate_columns or
destination.merge_keys. See Transform patterns — hash use cases
for guidance on surrogate-key-style hashes, hashdiffs, deterministic
identifiers, and PII boundaries.
Why slots jump from 35 to 60?¶
Slots 40–50 are reserved for your plugins. A common third-party addition is a validator at 50. See ADR-0003.
Tracking applied transformers¶
BaseTransformer exposes:
_mark_applied()— recordClassNameintransformers_applied_mark_applied("detail")— recordClassName(detail)_mark_skipped()— record nothing (no-op transformer)- no call → default: record
ClassName
The tracking label ends up in TransformRuntimeInfo.transformers_applied and
is serialized inside the attempt's transform object in the v6 dataflow
record. It is not a second root-level phase projection.
When missing_column_policy="ignore", typed value and masking transformers
count only rules that reference at least one existing column. If every rule is
skipped, the transformer is not added to transformers_applied. Schema hints
that do not match runtime columns produce one summary warning and do not mark
SchemaConverter applied. Projection and final sanitization are also recorded
only when they add a real rename/select/drop/reorder operation.
Value and masking operations are compiled to native expressions. One rule that
targets multiple columns resolves schema once and adds one Spark withColumns
or Polars with_columns projection. Rules still run sequentially so metadata
order and multiple rules on the same column remain observable. No Python UDF,
Spark action, or Polars data collection is used by these transformers.
String normalization follows a portable contract: trim removes ASCII U+0020
only, regex_replace accepts DataCoolie's conservative cross-engine regex v1,
and replacement text is literal. Typed fill/redact values are validated before
the native plan is changed. Partial masking never passes a short non-empty PII
value through unchanged.
Failure semantics¶
Transformers that raise TransformError are not wrapped — the driver sees
the original exception. Any other exception is wrapped by the pipeline into a
TransformError with details={"applied": [...so_far]} so the log records
which transformers ran before the failure. Both branches populate
TransformRuntimeInfo.message.