Docs

SQL Templates

Read the SQL Amfelt generates, every template per target platform, exactly as the connector renders it.

 

Amfelt generates the SQL that builds your data platform layers, and this is that SQL: every template, per target platform, exactly as the connector renders it. Nothing here is transcribed or summarized: the purpose line, the context fields and the body on each page are read from the template file itself.

Templates are keyed by target platform, not by SQL dialect. Several platforms share a language while differing in what they support, so a language-level key would merge platforms that genuinely need different templates. Only platforms with a SQL engine appear here. Object stores and open table formats have no engine to render for.

Sort or search the table to find a template, then follow it through for its full text.

PlatformTemplatePurposeLines
duckdbappend.sqlappend.sql — insert-only load; only inserts genuinely new rows (DuckDB)14
duckdbbridge.sqlbridge.sql — DROP legacy bare view (migration guard); CREATE _act and _hst.44
duckdbfragments.sqlfragments.sql — shared {{ define }} blocks for all duckdb history templates66
duckdbreplace.sqlreplace.sql — delete all rows then re-insert the full staging set (no versioning).11
duckdbscd1.sqlscd1.sql — upsert in place; physically delete records no longer in staging.31
duckdbscd2.sqlscd2.sql — two-statement SCD2 merge for DuckDB (SCD Type 2)22
duckdbsnapshot.sqlsnapshot.sql — diff-based snapshot for DuckDB54
postgresappend.sqlappend.sql — insert-only load, skip rows already present (idempotency)9
postgresbridge.sqlbridge.sql — DROP legacy bare view (migration guard); CREATE _act and _hst.44
postgresfragments.sqlfragments.sql — shared {{ define }} blocks for all postgres history templates57
postgresreplace.sqlreplace.sql — truncate history then re-insert full staging set (no versioning)8
postgresscd1.sqlscd1.sql — upsert in place; physically delete records no longer in staging42
postgresscd2.sqlscd2.sql — two-statement SCD2 MERGE for PostgreSQL (SCD Type 2)22
postgressnapshot.sqlsnapshot.sql — diff-based snapshot for PostgreSQL (state tables)26

Reading the context fields  

Each page lists the fields its template reads from the render context. That list is the root context only, not the fields of a collection the template ranges over. The root fields are what a caller supplies, while a ranged element’s fields belong to the element type.

The list is parsed from each template rather than maintained by hand, which is the point of generating this reference rather than publishing a copy of it.


Last updated on October 31, 2026