Turbo Transforms
Write, understand, and debug SQL, TypeScript, and dynamic table transforms for Turbo pipeline configurations.
Identify what the user needs (decode, filter, reshape, combine, custom logic, or lookup joins), then use the relevant section below. If generating a complete pipeline YAML (not just a transform snippet), always validate with goldsky turbo validate before presenting it to the user.
Reference files for specialized topics:
references/evm-patterns.md— Advanced EVM patterns (decode-once-filter-many, UNION ALL, schema normalization)references/typescript-transforms.md— TypeScript/WASM script transforms and handler transformsreferences/dynamic-tables.md— Dynamic table transforms (allowlists, lookup joins)references/solana-patterns.md— Solana instruction/log decoding and function examples
Transform Basics
YAML Structure
Required Fields
Referencing Data
- Reference sources by their YAML key name:
FROM my_source - Reference other transforms by their YAML key name:
FROM my_transform - No need for a
fromfield in SQL transforms — theFROMclause in SQL handles it
SQL Streaming Limitations
Turbo SQL is powered by Apache DataFusion in streaming mode. The following are NOT supported:
- Joins — use
dynamic_tabletransforms for lookup-style joins instead - Aggregations (GROUP BY, COUNT, SUM, AVG) — use
postgres_aggregatesink instead - Window functions (OVER, PARTITION BY, ROW_NUMBER)
- Subqueries — use transform chaining instead
- CTEs (WITH...AS) are supported
The _gs_op Column
Every record includes a _gs_op column that tracks the operation type: 'i' (insert), 'u' (update), 'd' (delete). Preserve this column through transforms for correct upsert semantics in database sinks.
Key SQL Functions
Quick reference for the most-used functions. For the complete function reference, see SQL transforms in the docs.
evm_log_decode() — Decode Raw EVM Logs
Returns decoded.event_signature (event name) and decoded.event_params[N] (1-indexed parameters as strings).
Example:
Tips: Backtick-escape reserved words (`data`, `decoded`). Include all event ABIs in one array. Pre-filter by contract address at the source level for efficiency.
Other Key Functions
Common Transform Patterns
Table Aliasing
Simple Filtering
Column Projection and Aliasing
Type Casting and Numeric Scaling
Conditional Logic with CASE WHEN
Exclusion Filters
Transform Chaining
Build multi-step pipelines where each transform reads from the previous:
UNION ALL — Combining Multiple Event Types
Combine transforms with identical schemas into a single output:
All branches must have the same columns in the same order. Use '' or 0 as placeholders.
For advanced EVM patterns (decode-once-filter-many, normalizing disparate events, multi-event activity feeds), read references/evm-patterns.md.
Source-Level Filtering
Filter data at the source before it reaches transforms for efficiency:
- Source
filter:→ coarse pre-filtering (contract addresses, block ranges) - Transform
WHERE→ fine-grained filtering (event types, parameter values, exclusions)
Sink Batching Configuration
Debugging Transforms
"Unknown source reference" — FROM clause name doesn't match any source/transform key. Check for typos.
"Missing primary_key" — Every transform needs primary_key. Almost always use id.
"Column not found" — Use goldsky turbo inspect <pipeline> -n <source_node> -p to see actual columns.
Empty results from decoded events:
- Verify ABI JSON matches actual contract events
- Check
decoded.event_signaturematches event name exactly (case-sensitive) - Ensure
addressfilter matches correct contract - Parameters are 1-indexed:
decoded.event_params[1], not[0]
Type mismatch in UNION ALL — All branches need identical column counts and compatible types.
TypeScript / WASM Script Transforms
For logic SQL can't express: custom parsing, BigInt arithmetic, stateful processing. Schema types: string, uint64, int64, float64, boolean, bytes.
Key rules: define function invoke(data), return null to filter, return object matching schema, no async/await or external imports.
See references/typescript-transforms.md for full docs, examples, and the SQL-vs-script decision table. Also includes Handler transforms for HTTP enrichment.
Dynamic Table Transforms
Updatable lookup tables for allowlists, blocklists, and join-style enrichment — without redeploying. Backed by PostgreSQL (durable) or in-memory (fast). Use dynamic_table_check('table_name', column) in SQL.
See references/dynamic-tables.md for full config, backend options, REST API updates, and wallet-tracking example.
Throttle Transform (Flow Control)
Caps the throughput of a stream by buffering records into batches and emitting each batch on a fixed minimum interval. Throttle does not modify data — every input record passes through unchanged. Use it to:
- Stay under rate limits of downstream sinks or external APIs
- Smooth bursty sources into a steady, predictable rate
- Pace records into an HTTP
handlerso the receiving service is not overwhelmed - Slow down processing during development or testing
A batch is flushed downstream when both max_batch_size records have accumulated and min_batch_interval has elapsed since the previous batch. Effective max throughput ≈ max_batch_size / min_batch_interval records per second.
Best practices:
- Place throttle close to the bottleneck (just before the rate-limited sink/handler) so upstream transforms still process at full speed.
- Tune
max_batch_sizeto match the downstream sink's preferred batch size. - Throttle is a
transform— chain other transforms downstream from it the same way you would any other transform (e.g.from: throttledin a sink). - Throttle does not have a
primary_keyfield (records pass through unchanged). - Remove throttle in production where possible; it caps throughput by design.
Solana Transform Patterns
IDL-based instruction decoding, program-specific decoders (Token, System, Stake, Vote), SPL token tracking.
See references/solana-patterns.md for all built-in decoders, full example pipeline, and array/JSON/hex function usage.
Related
/turbo-builder— Build and deploy pipelines interactively using these transforms/turbo-doctor— Diagnose and fix pipeline issues (including transform errors)/turbo-pipelines— Pipeline YAML configuration and architecture reference/turbo-operations— Lifecycle commands and monitoring reference/datasets— Blockchain dataset and chain prefix reference


