Skip to main content

Overview

SQL transforms let you process streaming data with SQL. They run on Apache DataFusion, so the dialect is standard DataFusion SQL — with Turbo-specific extensions for blockchain data. See the SQL Functions Reference for the full list of built-in functions.
Streaming SQL Limitations: Joins, aggregations, and window functions are not supported in streaming mode. Each transform must read from a single base table. Use dynamic tables for lookup-style joins and chain SQL transforms for multi-step logic.

Basic Configuration

Parameters

string
required
Must be sql
string
required
The column that uniquely identifies each row (e.g., id, transaction_hash, log_index)
string
required
The SQL query to execute. Reference sources or upstream transforms by name directly in the FROM clause — there is no separate from: field for SQL transforms.

Supported SQL Features

SELECT and Projections

Select specific columns from your data:

WHERE Clauses (Filtering)

Filter rows based on conditions:

Column Transformations

Transform column values using functions:

CAST and Type Conversions

Convert between data types:

String Functions

Common string operations:

Date and Time Functions

Work with timestamps:

Array Functions

Process array columns:

Conditional Logic (CASE)

Use CASE statements for conditional transformations:

Adding Literal Columns

Add constant values or labels:

Custom SQL Functions

Turbo pipelines includes 100+ custom SQL functions for blockchain data processing:
  • EVM Functions - Decode logs with evm_log_decode(), hash with _gs_keccak256()
  • Solana Functions - Decode instructions, analyze transactions, track balances
  • Large Number Arithmetic - U256/I256 functions for precise token calculations
  • Array Processing - array_filter(), array_enumerate(), zip_arrays()
  • JSON Functions - Query and construct JSON with json_query(), json_object()
  • Encoding - Hex, Base58, and binary conversions
Example: Decode ERC-20 Transfer Events
Example: Calculate Token Amounts with U256
U256/I256 types support standard operators (+, -, *, /, %) which are automatically rewritten by the SQL preprocessor to their function equivalents.
See the SQL Functions Reference for the complete list of functions with detailed examples.

Dynamic Table Integration

Use dynamic_table_check() to filter based on values in a dynamic table:
See the Dynamic Tables documentation for more details.

Limitations

The following SQL features are not supported in streaming mode:
  • Joins - Use dynamic tables for lookup-style joins
  • Aggregations (GROUP BY, COUNT, SUM, etc.) - Require stateful processing; use postgres aggregate sinks for aggregations at write time
  • Window functions - Not supported in streaming context
Each SQL transform must read from a single base source or upstream transform. CTEs (WITH ...) and derived subqueries in the FROM clause are supported as long as they ultimately reference one base table. UNION ALL between queries on the same base table is also allowed.

Best Practices

Only select the columns you need to reduce data transfer and memory usage:
Apply filters as early as possible in your pipeline. Chain SQL transforms by referencing upstream transform names in the FROM clause:
Cast to the correct types for your use case:
_gs_op (the change-data-capture operation column used by upsert-aware sinks) is automatically carried through SQL transforms — you do not need to select it explicitly. You can still include it if you want to project or reorder it:
Make your transformed data self-documenting:

Example: Multi-Chain Token Transfers

Here’s a complete example processing token transfers from multiple chains: