Skip to content
AnswerWell geo Documentation

Research · 8 min read · Answerwell

Event Stream Pipelines: Ingestion, SQL Transforms, and Apache Iceberg

How Basin Pipelines streams, SQL pipelines, and sinks deliver events to R2 and Iceberg tables, with Workers bindings, Logpush, and verification.

This page summarizes Cloudflare Basin Pipelines documentation: a serverless streaming ingest path that sits inside the wider Basin analytics platform (Basin Catalog Apache Iceberg tables on R2, queryable with Basin SQL). If you need to land high-volume JSON events from Workers, HTTP clients, or Logpush without running your own streaming cluster—and you want SQL filtering or reshaping before storage—Basin Pipelines is the piece you configure.

Ingest, transform, and load streaming data into Apache Iceberg or Parquet in R2.

— Cloudflare, Basin Pipelines

Basin Pipelines ingests events, transforms them with SQL, and delivers them to R2 as Iceberg tables or as Parquet and JSON files. Whether you are processing server logs, mobile application events, IoT telemetry, or clickstream data, Basin Pipelines provides durable ingestion via HTTP endpoints or Worker bindings, SQL-based transformations, and exactly-once delivery to R2.

— Cloudflare, Basin Pipelines

Basin Pipelines architecture: streams, pipelines, and sinks

Section titled “Basin Pipelines architecture: streams, pipelines, and sinks”

Basin Pipelines splits responsibilities into three resources you wire together with SQL: a stream receives events, a pipeline runs INSERT INTO … SELECT … transformation SQL, and a sink writes results to storage.

Resource Role Typical configuration
Stream Durable buffered queue; HTTP and/or Worker ingest JSON schema optional
Pipeline SQL from stream name to sink name One or more INSERT statements
Sink Destination on R2 or Basin Catalog Iceberg table, Parquet, or JSON files

Streams are durable, buffered queues that receive and store events for processing in Basin Pipelines. They provide reliable data ingestion via HTTP endpoints and Worker bindings, ensuring no data loss even during downstream processing delays or failures.

— Cloudflare, Streams

Sinks define destinations for your data in Basin Pipelines. They support writing to Basin Catalog as Apache Iceberg tables or to R2 as raw JSON or Parquet files. Sinks provide exactly-once delivery guarantees, ensuring events are never duplicated or dropped.

— Cloudflare, Sinks

A single stream can feed multiple pipelines, which helps when the same events must go to analytics and archival paths with different SQL. For queryable warehouses, prefer a Basin Catalog sink (Iceberg); plain R2 sinks are for file lakes without catalog semantics. Available sinks lists R2 and Basin Catalog.

Plan and limits: Workers plan, ingest throughput, and legacy pipelines

Section titled “Plan and limits: Workers plan, ingest throughput, and legacy pipelines”

Basin Pipelines targets real-time event volumes (logs, clickstreams, Worker telemetry) where you want managed buffering and SQL at ingest time. It is available on the Workers Paid plan per Basin Pipelines. Pipelines SQL handles routing and row-level transforms; aggregations, joins, and reporting belong in Basin SQL after data lands in Iceberg.

Each stream can ingest up to 1 GB/s, raised from 5 MB/s:

Each Basin Pipelines stream can now ingest up to 1 GB/s, increased from 5 MB/s. The higher per-stream limit gives high-volume application events, telemetry, and logs more room to grow without splitting ingestion across streams solely to stay within the previous limit.

— Cloudflare, Basin Pipelines ingest limit increased to 1 GB/s

For other caps, the changelog points to Basin Pipelines limits (not included in this cluster).

Pipelines created before September 25, 2025 via the legacy API follow a deprecation path. New pipelines add SQL transforms, separate stream/sink/pipeline resources, optional schemas, and Iceberg/Parquet/JSON outputs. Identify legacy pipelines in the dashboard or with wrangler basin pipelines list.

Create a first pipeline: wrangler basin pipelines setup and tokens

Section titled “Create a first pipeline: wrangler basin pipelines setup and tokens”

The fastest path is the interactive wizard, which can create an R2 bucket and enable Basin Catalog when they are missing:

The setup command automatically creates the R2 bucket and enables Basin Catalog if they do not already exist, so you do not need to create them beforehand.

— Cloudflare, Getting started

  1. Create an API token with permissions for Basin Pipelines (Read, Send, Edit), Basin Catalog, Basin SQL, and Workers R2 Storage as described in Build an end-to-end data pipeline and Getting started.

  2. Define a JSON schema file for structured events (field names and types), as in Getting started.

  3. Run setup with npx wrangler basin pipelines setup.

  4. Choose an HTTP endpoint and/or Worker binding, a Basin Catalog (Iceberg) sink, and Simple ingestion SQL (INSERT INTO … SELECT * FROM …) unless you need filters in pipeline SQL.

  5. Note the HTTP ingest URL (https://{stream-id}.ingest.cloudflare.com), stream ID for Wrangler bindings, and warehouse name for Basin SQL—see Writing to streams and Getting started.

Manage pipelines, manage streams, and manage sinks cover dashboard and CLI equivalents. The full command family is in Wrangler commands and Basin Pipelines Wrangler commands.

Send events: HTTP ingest endpoint and Worker stream bindings

Section titled “Send events: HTTP ingest endpoint and Worker stream bindings”

After setup, post an array of objects matching your schema to the stream endpoint (Getting started):

curl -X POST https://{stream-id}.ingest.cloudflare.com \
-H "Content-Type: application/json" \
-d '[{"user_id": "user_12345", "event_type": "purchase", "amount": 29.99}]'

Enable HTTP authentication when the endpoint is exposed to the public internet; scope a token with Basin Pipelines Send permission (Prompt an agent to build with Basin).

Worker binding: env.BINDING.send([...]) with stream in Wrangler

Section titled “Worker binding: env.BINDING.send([...]) with stream in Wrangler”

Bindings point at the stream ID, not the pipeline ID (Basin CLI guide):

{
"pipelines": [
{
"binding": "EVENTS",
"stream": "<STREAM_ID>"
}
]
}

The binding field was renamed from pipeline to stream; the old key still works with a deprecation warning (Pipeline binding configuration field renamed to stream). Runtime API remains env.MY_PIPELINE.send(...).

Run wrangler types so TypeScript uses schema-specific record types instead of generic Pipeline<PipelineRecord> (Dropped event metrics, typed Pipelines bindings, and improved setup, Writing to streams).

Pipeline SQL: filter, reshape, and fan out to multiple Iceberg tables

Section titled “Pipeline SQL: filter, reshape, and fan out to multiple Iceberg tables”

Pipelines execute SQL that reads a stream as a table and writes to sinks by name:

INSERT INTO my_sink SELECT * FROM my_stream

For transforms at ingest time, use expressions and WHERE clauses. Cloudflare’s clickstream example filters bots and parses domains (Pipelines now supports SQL transformations and Apache Iceberg):

INSERT INTO events_table
SELECT
user_id,
lower(event) AS event_type,
regexp_match(url, '^https?://([^/]+)')[1] AS domain
FROM events_json
WHERE event = 'page_view'
AND NOT regexp_like(user_agent, '(?i)bot|spider');

One pipeline may contain multiple semicolon-separated INSERT statements, each reading the same stream and filtering to different sinks (Manage pipelines, SELECT statements):

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';

A full walkthrough routes Bluesky Jetstream events into five Iceberg tables via one --sql-file (Fan out a stream to multiple Iceberg tables). Pipeline SQL cannot be modified after creation; changing routing means delete and recreate (Fan out a stream to multiple Iceberg tables).

Stream schema validation: structured vs unstructured JSON and dropped events

Section titled “Stream schema validation: structured vs unstructured JSON and dropped events”

Structured streams and supported field types

Section titled “Structured streams and supported field types”

Structured streams require events to match declared fields and types (string, int64, float64, bool, timestamp, json, list, struct, etc.). Schema changes are not supported after stream creation (Manage streams). Unstructured streams accept any JSON into a single value column.

Why rows disappear after a successful HTTP 200

Section titled “Why rows disappear after a successful HTTP 200”

When stream events don’t match the expected schema, Pipelines accepts them during ingestion but drops them when attempting to deliver them to the sink.

— Cloudflare, Dropped event metrics, typed Pipelines bindings, and improved setup

Error families include missing_field, type_mismatch, parse_failure, and null_value (Metrics and analytics). Inspect the pipeline Errors tab in the dashboard or GraphQL dataset pipelinesUserErrorsAdaptiveGroups (same changelog post). Prefer wrangler types and pre-send validation in Workers to catch mismatches before deploy.

Basin Catalog sinks roll data on a roll interval (for example 30–60 seconds); allow a few minutes before the first Iceberg files appear (Build an end-to-end data pipeline, Basin CLI guide). Iceberg tables may include an __ingest_ts partition column (Build an end-to-end data pipeline).

Logpush to Basin Pipelines: Cloudflare logs into Parquet or Iceberg

Section titled “Logpush to Basin Pipelines: Cloudflare logs into Parquet or Iceberg”

Logpush can use Basin Pipelines as a native destination instead of raw JSON buckets (Enable Basin Pipelines, Logpush as a source):

With this release, you can now send your logs directly to Pipelines to ingest, transform, and store your logs in R2 as Parquet files or Apache Iceberg tables managed by R2 Data Catalog.

— Cloudflare, Cloudflare Pipelines as a Logpush destination

Supported datasets:

Scope Datasets
Zone http_requests, firewall_events, dns_logs
Account workers_trace_events

Configuring the job is described in Enable Basin Pipelines.

Infrastructure as code: Terraform resources for stream, sink, and pipeline

Section titled “Infrastructure as code: Terraform resources for stream, sink, and pipeline”

From Cloudflare Terraform provider v5.19.0+, you can declare cloudflare_r2_data_catalog, cloudflare_pipeline_stream, cloudflare_pipeline_sink, and cloudflare_pipeline (Pipelines and R2 Data Catalog now supported in Terraform, Terraform). Terraform permission group names may still say “R2 Data Catalog” while the product is Basin Catalog (Terraform).

Common mistakes when wiring streams, sinks, and SQL

Section titled “Common mistakes when wiring streams, sinks, and SQL”

Further examples: Basin Pipelines examples, Build an end-to-end data pipeline, and Tutorials and examples.

  1. List resources with wrangler basin pipelines list, wrangler basin pipelines streams get <NAME_OR_ID>, and confirm the HTTP endpoint or binding stream ID matches Writing to streams.
  2. Send a small test batch to the ingest URL or deploy a Worker that calls env.<BINDING>.send([...]) per Getting started or Basin CLI guide.
  3. Open the pipeline in the Cloudflare dashboard under Basin Pipelines and review the Metrics and Errors tabs (Metrics and analytics).
  4. After the sink roll interval, run wrangler basin sql query "<WAREHOUSE>" "SELECT * FROM <namespace>.<table> LIMIT 10" with WRANGLER_BASIN_SQL_AUTH_TOKEN set (Query data).
  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about.