Learn how to:
- Create pipelines with SQL transformations
- View pipeline configuration and SQL
- Update pipelines after a stream or sink changes
- Fix a failed pipeline
- Delete pipelines when no longer needed
Pipelines execute SQL statements that define how data flows from streams to sinks.
-
In the Cloudflare dashboard, go to the Basin Pipelines page.
Go to Pipelines ↗ -
Select Create Pipeline to launch the pipeline creation wizard.
-
Follow the wizard to configure your stream, sink, and SQL transformation.
To create a pipeline, run the basin pipelines create command:
npx wrangler basin pipelines create my-pipeline --sql "INSERT INTO my_sink SELECT * FROM my_stream"yarn wrangler basin pipelines create my-pipeline --sql "INSERT INTO my_sink SELECT * FROM my_stream"pnpm wrangler basin pipelines create my-pipeline --sql "INSERT INTO my_sink SELECT * FROM my_stream"You can also provide SQL from a file:
npx wrangler basin pipelines create my-pipeline --sql-file pipeline.sqlyarn wrangler basin pipelines create my-pipeline --sql-file pipeline.sqlpnpm wrangler basin pipelines create my-pipeline --sql-file pipeline.sqlAlternatively, to use the interactive setup wizard that helps you configure a stream, sink, and pipeline, run the basin pipelines setup command:
npx wrangler basin pipelines setupyarn wrangler basin pipelines setuppnpm wrangler basin pipelines setupPipelines support SQL statements for data transformation. For complete syntax, supported functions, and data types, see the SQL reference.
Common patterns include:
Transfer all data from stream to sink:
INSERT INTO my_sink SELECT * FROM my_streamFilter events based on conditions:
INSERT INTO my_sink
SELECT * FROM my_stream
WHERE event_type = 'purchase' AND amount > 100Choose only the fields you need:
INSERT INTO my_sink
SELECT user_id, event_type, timestamp, amount
FROM my_streamApply transformations to fields:
INSERT INTO my_sink
SELECT
user_id,
UPPER(event_type) as event_type,
timestamp,
amount * 1.1 as amount_with_tax
FROM my_streamA single pipeline can run multiple INSERT statements, separated by semicolons. Each statement reads from the same stream and writes to a different sink, so you can route ("fan out") events from one stream into several tables based on their content.
This avoids running a separate pipeline for each destination. Each statement filters the stream with its own WHERE clause and projects only the columns relevant to that table. This can also be a used as a cost optimization as you will be billed once for the transformations, not per statement.
INSERT INTO purchases_sink
SELECT user_id, product_id, amount FROM my_stream
WHERE event_type = 'purchase';
INSERT INTO page_views_sink
SELECT user_id, product_id FROM my_stream
WHERE event_type = 'view_product';For a complete example that fans a live event stream out into five tables, refer to Fan out a stream to multiple Iceberg tables.
-
In the Cloudflare dashboard, go to the Basin Pipelines page.
-
Select a pipeline to view its SQL transformation, connected streams/sinks, and associated metrics.
To view a specific pipeline, run the basin pipelines get command with either the pipeline ID or pipeline name:
npx wrangler basin pipelines get <PIPELINE_NAME_OR_ID>yarn wrangler basin pipelines get <PIPELINE_NAME_OR_ID>pnpm wrangler basin pipelines get <PIPELINE_NAME_OR_ID>To list all pipelines in your account, run the basin pipelines list command:
npx wrangler basin pipelines listyarn wrangler basin pipelines listpnpm wrangler basin pipelines listAfter a stream or sink changes, for example when you update a sink's credentials, a pipeline keeps the earlier version until you update the pipeline. Updating a failed pipeline also retries it.
-
In the Cloudflare dashboard, go to the Basin Pipelines page.
Go to Pipelines ↗ -
Select the pipeline.
-
Select Update pipeline. The button appears only when a stream or sink the pipeline uses has changed.
The API token for this request must have Basin Pipelines Edit permission.
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/pipelines/v1/pipelines/$PIPELINE_ID/update_tables" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"To check whether a pipeline needs an update, get the pipeline and read its outdated field.
A failed pipeline stops processing data. Its page in the dashboard shows the reason, and the API returns it in the pipeline's failure_reason field.
Cause: One cause is that the pipeline can no longer write to its sink, because the sink's credentials expired or were revoked.
Fix: Update the sink's credentials, then update the pipeline. Updating a failed pipeline retries it.
Verify: The pipeline's status changes from failed to running.
Deleting a pipeline stops data flow from the connected stream to sink.
-
In the Cloudflare dashboard, go to the Basin Pipelines page.
-
Select the pipeline you want to delete. 3. In the Settings tab, and select Delete.
To delete a pipeline, run the basin pipelines delete command:
npx wrangler basin pipelines delete <PIPELINE_ID>yarn wrangler basin pipelines delete <PIPELINE_ID>pnpm wrangler basin pipelines delete <PIPELINE_ID>Pipeline SQL cannot be modified after creation. To change the SQL transformation, you must delete and recreate the pipeline.