Skip to content

feat: transformers as UDAFs v0 — just run the pipeline - #61

Merged
claude-agent-ahrzb[bot] merged 2 commits into
masterfrom
transformers-run-the-pipeline
Jul 29, 2026
Merged

feat: transformers as UDAFs v0 — just run the pipeline#61
claude-agent-ahrzb[bot] merged 2 commits into
masterfrom
transformers-run-the-pipeline

Conversation

@claude-agent-ahrzb

Copy link
Copy Markdown

Loop 5, scoped per the design dialogue: no desugaring (the optimization pass comes later), no sklearn.* namespace (needs the sklearn index) — transformers are opaque objects and fit literally runs them. Spec: docs/superpowers/specs/2026-07-29-transformers-run-the-pipeline-design.md.

embed = Pipeline([("sc", StandardScaler()), ("pca", PCA(2))])   # found in caller scope
p = SQLProjection(
    "SELECT embed(struct_pack(a := age, f := fare)) OVER (PARTITION BY country) AS e,"
    " age - avg(age) OVER () AS c, name FROM __THIS__"
).fit(train)
out = p.transform(table)      # NEW: batch apply
  • Resolution: explicit transformers= registry, then caller scope (FROM df idiom), guarded by duckdb_functions() so a local variable can never shadow real SQL. Captured objects surface on p.transformers.
  • Plan: a second step kind — FitStep(kind="fit", transformer, features, keys) reading the level table; the executor grows one branch (groupby keys → clone()fit). Everything else (names, reads, DAG order) unchanged.
  • Apply: transform(table) runs serving_sql (helper feature/key columns ride along), applies fitted clones per group, splices each output column in place of its helper block. Unseen group → NULL, the exact-join policy.
  • Gate: transformer columns vs an independent clone-per-group sklearn reference; SQL columns still bit-exact vs DuckDB. Named refusals for ORDER BY/frames/FILTER on transformer windows, non-final levels, nested calls, fn(*) (the parser erases the star — refused loudly rather than silently fitting zero features), unnamed struct fields, and namespaced names.

Root pytest 507 passed + 1 xfailed; confit untouched.

🤖 Generated with Claude Code

Window calls with names unknown to DuckDB resolve to transformer
objects: explicit registry first, then the caller's Python scope (the
FROM-df replacement-scan idiom), guarded by the oracle's function
catalog so real SQL can never be shadowed. Bundles are a column or
struct_pack(named := exprs); PARTITION BY fits a clone per group.

Per AmirHossein's scoping: no desugaring (that optimization comes
later) and no sklearn.* namespace yet — fit literally runs the sklearn
object per group via a new plan step kind ("fit"), and a new batch
transform(table) runs serving_sql through DuckDB then applies the
fitted clones over helper feature/key columns, splicing outputs in
place. Unseen groups get NULL (the exact-join policy). infer through
Confit stays NotImplemented.

Gate: transformer columns check against an independent clone-per-group
sklearn reference; SQL columns unchanged (bit-exact vs DuckDB). Named
refusals: unknown names, ORDER BY/frames/FILTER on transformer windows,
non-final levels, nested calls, fn(*) (the parser erases the star),
unnamed struct fields, namespaced names. Root pytest 507+1.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Converged design dialogue 2026-07-29: per-group weights as params data
(instance ids over the existing join), a declared scalar-UDF protocol with
PythonTransform as subclass, InferFn udfs= API, extern helper family in
Confit. Parked until the go.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@claude-agent-ahrzb
claude-agent-ahrzb Bot merged commit fe08b63 into master Jul 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant