R2 Data Catalog now supports automatic snapshot expiration for Apache Iceberg tables.
In Apache Iceberg, a snapshot is metadata that represents the state of a table at a given point in time. Every mutation creates a new snapshot which enable powerful features like time travel queries and rollback capabilities but will accumulate over time.
Without regular cleanup, these accumulated snapshots can lead to:
Metadata overhead
Slower table operations
Increased storage costs.
Snapshot expiration in R2 Data Catalog automatically removes old table snapshots based on your configured retention policy, improving performance and storage costs.
Snapshot expiration uses two parameters to determine which snapshots to remove:
--older-than-days: age threshold in days
--retain-last: minimum snapshot count to retain
Both conditions must be met before a snapshot is expired, ensuring you always retain recent snapshots even if they exceed the age threshold.
This feature complements automatic compaction, which optimizes query performance by combining small data files into larger ones. Together, these automatic maintenance operations keep your Iceberg tables performant and cost-efficient without manual intervention.
R2 SQL now supports aggregation functions, GROUP BY, HAVING, along with schema discovery commands to make it easy to explore your data catalog.
Aggregation Functions
You can now perform aggregations on Apache Iceberg tables in R2 Data Catalog using standard SQL functions including COUNT(*), SUM(), AVG(), MIN(), and MAX(). Combine these with GROUP BY to analyze data across dimensions, and use HAVING to filter aggregated results.
-- Calculate average transaction amounts by departmentSELECT department, COUNT(*), AVG(total_amount)FROM my_namespace.sales_dataWHERE region = 'North'GROUP BY departmentHAVING COUNT(*) > 50ORDER BY AVG(total_amount) DESC
New metadata commands make it easy to explore your data catalog and understand table structures:
SHOW DATABASES or SHOW NAMESPACES - List all available namespaces
SHOW TABLES IN namespace_name - List tables within a namespace
DESCRIBE namespace_name.table_name - View table schema and column types
β― npx wrangler r2 sql query "{ACCOUNT_ID}_{BUCKET_NAME}" "DESCRIBE default.sales_data;" β οΈ wrangler 4.54.0βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββ¬βββββββββββ¬ββββββββββββββββββ¬ββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ column_name β type β required β initial_default β write_default β doc βββββββββββββββββββββΌβββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β sale_id β BIGINT β false β β β Unique identifier for each sales transaction βββββββββββββββββββββΌβββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β sale_timestamp β TIMESTAMPTZ β false β β β Exact date and time when the sale occurred (used for partitioning) βββββββββββββββββββββΌβββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β department β TEXT β false β β β Product department (8 categories: Electronics, Beauty, Home, Toys, Sports, Food, Clothing, Books) βββββββββββββββββββββΌβββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β category β TEXT β false β β β Product category grouping (4 categories: Premium, Standard, Budget, Clearance) βββββββββββββββββββββΌβββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β region β TEXT β false β β β Geographic sales region (5 regions: North, South, East, West, Central) βββββββββββββββββββββΌβββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β product_id β INT β false β β β Unique identifier for the product sold βββββββββββββββββββββΌβββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β quantity β INT β false β β β Number of units sold in this transaction (range: 1-50) βββββββββββββββββββββΌβββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β unit_price β DECIMAL(10, 2) β false β β β Price per unit in dollars (range: $5.00-$500.00) βββββββββββββββββββββΌβββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β total_amount β DECIMAL(10, 2) β false β β β Total sale amount before tax (quantity Γ unit_price with discounts applied) βββββββββββββββββββββΌβββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β discount_percent β INT β false β β β Discount percentage applied to this sale (0-50%) βββββββββββββββββββββΌβββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β tax_amount β DECIMAL(10, 2) β false β β β Tax amount collected on this sale βββββββββββββββββββββΌβββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β profit_margin β DECIMAL(10, 2) β false β β β Profit margin on this sale as a decimal percentage βββββββββββββββββββββΌβββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β customer_id β INT β false β β β Unique identifier for the customer who made the purchase βββββββββββββββββββββΌβββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β is_online_sale β BOOLEAN β false β β β Boolean flag indicating if sale was made online (true) or in-store (false) βββββββββββββββββββββΌβββββββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β sale_date β DATE β false β β β Calendar date of the sale (extracted from sale_timestamp) βββββββββββββββββββββ΄βββββββββββββββββ΄βββββββββββ΄ββββββββββββββββββ΄ββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββRead 0 B across 0 files from R2On average, 0 B / s
To learn more about the new aggregation capabilities and schema discovery commands, check out the SQL reference. If you're new to R2 SQL, visit our getting started guide to begin querying your data.
You can now enable compaction for individual Apache Iceberg βοΈ tables in R2 Data Catalog, giving you fine-grained control over different workloads.
# Enable compaction for a specific table (no token required)npx wrangler r2 bucket catalog compaction enable <BUCKET> <NAMESPACE> <TABLE> --target-size 256
Today, we are launching the new Cloudflare Pipelines: a streaming data platform that ingests events, transforms them with SQL, and writes to R2 as Apache Iceberg βοΈ tables or Parquet files.
Pipelines can receive events via HTTP endpoints or Worker bindings, transform them with SQL, and deliver to R2 with exactly-once guarantees. This makes it easy to build analytics-ready warehouses for server logs, mobile application events, IoT telemetry, or clickstream data without managing streaming infrastructure.
For example, here is a pipeline that ingests clickstream events and filters out bot traffic while extracting domain information:
INSERT into events_tableSELECT user_id, lower(event) AS event_type, to_timestamp_micros(ts_us) AS event_time, regexp_match(url, '^https?://([^/]+)')[1] AS domain, url, referrer, user_agentFROM events_jsonWHERE event = 'page_view' AND NOT regexp_like(user_agent, '(?i)bot|spider');
Get started by creating a pipeline in the dashboard or running a single command in Wrangler:
Today, we are launching the open beta for R2 SQL: A serverless, distributed query engine that can efficiently analyze petabytes of data in Apache Iceberg βοΈ tables managed by R2 Data Catalog.
R2 SQL is ideal for exploring analytical and time-series data stored in R2, such as logs, events from Pipelines, or clickstream and user behavior data.
If you already have a table in R2 Data Catalog, running queries is as simple as:
npx wrangler r2 sql query YOUR_WAREHOUSE "SELECT user_id, event_type, valueFROM events.user_eventsWHERE event_type = 'CHANGELOG' or event_type = 'BLOG' AND __ingest_ts > '2025-09-24T00:00:00Z'ORDER BY __ingest_ts DESCLIMIT 100"
To get started with R2 SQL, check out our getting started guide or learn more about supported features in the SQL reference. For a technical deep dive into how we built R2 SQL, read our blog post βοΈ.
Compaction is the process of taking a group of small files and combining them into fewer larger files. This is an important maintenance operation as it helps ensure that query performance remains consistent by reducing the number of files that needs to be scanned.
To enable automatic compaction in R2 Data Catalog, find it under R2 Data Catalog in your R2 bucket settings in the dashboard.
Today, we are launching R2 Data Catalog in open beta, a managed Apache Iceberg catalog built directly into your Cloudflare R2 bucket.
If you are not already familiar with it, Apache Iceberg βοΈ is an open table format designed to handle large-scale analytics datasets stored in object storage, offering ACID transactions and schema evolution. R2 Data Catalog exposes a standard Iceberg REST catalog interface, so you can connect engines like Spark, Snowflake, and PyIceberg to start querying your tables using the tools you already know.
To enable a data catalog on your R2 bucket, find R2 Data Catalog in your buckets settings in the dashboard, or run:
npx wrangler r2 bucket catalog enable my-bucket
And that's it. You'll get a catalog URI and warehouse you can plug into your favorite Iceberg engines.
Visit our getting started guide for step-by-step instructions on enabling R2 Data Catalog, creating tables, and running your first queries.
Pipelines let you ingest high volumes of real time data, without managing the underlying infrastructure. A single pipeline can ingest up to 100 MB of data per second, via HTTP or from a Worker. Ingested data is automatically batched, written to output files, and delivered to an R2 bucket in your account. You can use Pipelines to build a data lake of clickstream data, or to store events from a Worker.
Create your first pipeline with a single command:
Create a pipelinebash
$ npx wrangler@latest pipelines create my-clickstream-pipeline --r2-bucket my-bucketπ Authorizing R2 bucket "my-bucket"π Creating pipeline named "my-clickstream-pipeline"β Successfully created pipeline my-clickstream-pipelineId: 0e00c5ff09b34d018152af98d06f5a1xvcName: my-clickstream-pipelineSources: HTTP: Endpoint: https://0e00c5ff09b34d018152af98d06f5a1xvc.pipelines.cloudflare.com/ Authentication: off Format: JSON Worker: Format: JSONDestination: Type: R2 Bucket: my-bucket Format: newline-delimited JSON Compression: GZIPBatch hints: Max bytes: 100 MB Max duration: 300 seconds Max records: 100,000π You can now send data to your pipeline!Send data to your pipeline's HTTP endpoint:curl "https://0e00c5ff09b34d018152af98d06f5a1xvc.pipelines.cloudflare.com/" -d '[{ ...JSON_DATA... }]'To send data to your pipeline from a Worker, add the following configuration to your config file:{ "pipelines": [ { "pipeline": "my-clickstream-pipeline", "binding": "PIPELINE" } ]}
Head over to our getting started guide for an in-depth tutorial to building with Pipelines.