Apache Iceberg REST Catalog, Warehouse SQL, and Table Maintenance
How Cloudflare Basin Catalog exposes Iceberg on R2, authenticate engines, query with Basin SQL, run maintenance, and connect Trino.
This page summarises Cloudflare documentation on Basin Catalog (formerly R2 Data Catalog), Basin SQL (formerly R2 SQL), and related Wrangler operations. Basin is a managed Apache Iceberg stack on R2: a REST catalog on the bucket, optional automatic table maintenance, pipelines that write Parquet tables, and a serverless SQL engine—so Spark, Snowflake, DuckDB, Trino, and others can share the same tables without egress fees.
Apache Iceberg and Basin Catalog: what the REST catalog is for
Section titled “Apache Iceberg and Basin Catalog: what the REST catalog is for”Apache Iceberg is an open table format for large analytics on object storage: ACID transactions, indexed metadata for file pruning, and schema evolution. A data catalog holds namespaces, table metadata, and pointers to the current snapshot; data files live in storage (here, R2).
Basin Catalog is a managed Apache Iceberg data catalog built directly into your R2 bucket. It exposes a standard Iceberg REST catalog interface, so you can connect the engines you already use, like Spark, Snowflake, and PyIceberg.
— Cloudflare, Basin Catalog
Think of a data catalog as a library’s index system. While books (your data) are physically distributed across shelves (object storage), the index provides a single source of truth about what books exist, their locations, and their latest editions.
— Cloudflare, Basin Catalog
Basin Catalog, formerly known as R2 Data Catalog, is now Generally Available. Existing configurations and APIs continue to work and will be deprecated in the future.
— Cloudflare, Basin Catalog
Basin Catalog enable on bucket: Catalog URI and Warehouse
Section titled “Basin Catalog enable on bucket: Catalog URI and Warehouse”You turn the catalog on per R2 bucket, then read Catalog URI and warehouse name for engine configuration and for Basin SQL.
Wrangler basin catalog: enable, disable, and status
Section titled “Wrangler basin catalog: enable, disable, and status”| Action | Command |
|---|---|
| Enable | wrangler basin catalog enable <BUCKET_NAME> |
| Disable | wrangler basin catalog disable <BUCKET_NAME> |
| Status / warehouse | wrangler basin catalog get <BUCKET_NAME> |
Legacy names such as wrangler r2 bucket catalog enable may still appear in older changelog entries; current references use the basin catalog family. See Wrangler commands (R2) and Manage catalogs.
Dashboard: wizard and Explorer
Section titled “Dashboard: wizard and Explorer”The dashboard offers a guided flow (bucket, table maintenance, review) and a Basin Catalog area with Settings, Explorer (namespaces, schema, metadata, maintenance), and Metrics. You can also enable catalog from the bucket Settings panel. Steps are in Get started and Manage catalogs.
Iceberg engine connection: which engine and how to authenticate
Section titled “Iceberg engine connection: which engine and how to authenticate”Engines attach via the Iceberg REST catalog and typically use vended SigV4 credentials for R2. Configuration examples exist for DuckDB, PyIceberg, Snowflake, Spark (Python and Scala), StarRocks, and Trino in Configuration examples.
Choose an Iceberg query engine by goal
Section titled “Choose an Iceberg query engine by goal”| Goal | Resource |
|---|---|
| Local SQL | DuckDB |
| Distributed SQL | Trino or StarRocks |
| Python | PyIceberg or Apache Spark with Python |
| Scala | Apache Spark with Scala |
| Data warehouse | Snowflake |
Choose a configuration example for your existing engine.
— Cloudflare, Tutorials and examples
For ad hoc exploration without running your own cluster, use Basin SQL (below). For production ETL, Spark or Basin Pipelines are common; for federated SQL at scale, Trino or StarRocks fit the distributed SQL row.
R2 API tokens: read-only vs read-write and vended credentials
Section titled “R2 API tokens: read-only vs read-write and vended credentials”Basin Catalog requires an R2 token with Admin Read only or Admin Read & Write (R2 API tokens):
- Read-only catalog ops (list namespaces, load tables, query): Admin Read only is enough.
- Write ops (create/drop tables, commits): Admin Read & Write is required.
- Object Read & Write tokens apply to the S3-compatible API only, not the catalog REST API.
Read-only operations (such as listing namespaces, loading tables, and querying data) work with an Admin Read only token (R2 Data Catalog read and R2 storage read).
— Cloudflare, Read-only tokens changelog
Note that credentials vended by the catalog inherit the R2 storage permissions of the token used to authenticate.
— Cloudflare, Read-only tokens changelog
Pipeline sinks and catalog writers need Admin Read & Write (often passed as --catalog-token). Details: Authenticate your Iceberg engine (within Manage catalogs).
Trino Iceberg REST catalog: r2.properties and Docker
Section titled “Trino Iceberg REST catalog: r2.properties and Docker”Below is an example of using Trino ↗︎ to connect to Basin Catalog.
— Cloudflare, Trino config example
Create a catalog directory and r2.properties with:
connector.name=iceberg- Native S3 for R2:
fs.native-s3.enabled=true,s3.region=auto, access key, secret, endpoint,s3.path-style-access=true - REST catalog:
iceberg.catalog.type=rest,iceberg.rest-catalog.uri,iceberg.rest-catalog.warehouse,iceberg.rest-catalog.security=OAUTH2,iceberg.rest-catalog.oauth2.token(your R2 authentication token)
Run Trino with the catalog mounted at /etc/trino/catalog, then verify with SHOW SCHEMAS IN r2; and sample DDL/DML as in Trino config example. Spark clients often set X-Iceberg-Access-Delegation: vended-credentials per Spark Python example.
Basin SQL: query warehouse from CLI, API, and dashboard
Section titled “Basin SQL: query warehouse from CLI, API, and dashboard”Basin SQL is Cloudflare’s serverless distributed engine for Iceberg tables in Basin Catalog—no long-lived query cluster.
Basin SQL, formerly known as R2 SQL, is now Generally Available. Existing R2 SQL APIs continue to work and will be deprecated in the future.
— Cloudflare, Basin SQL
Use the basin sql command family to query a warehouse:
— Cloudflare, Wrangler commands (Basin SQL)
wrangler basin sql query <WAREHOUSE_NAME> "SELECT * FROM <NAMESPACE>.<TABLE> LIMIT 10"Use the warehouse name from wrangler basin catalog get <BUCKET_NAME> or the catalog Settings in the dashboard. REST queries use POST https://api.sql.cloudflarestorage.com/api/v1/accounts/{ACCOUNT_ID}/basin-sql/query/{BUCKET_NAME} with a Bearer token; permissions are described in Query data. The dashboard Query data SQL editor supports exploration, EXPLAIN, and export—see Basin SQL query data.
Useful SQL surface includes SHOW DATABASES / namespaces and tables, DESCRIBE, JSON helpers (json_get_str, json_get_int, and related), and EXPLAIN FORMAT JSON. Unpartitioned tables are supported; for tables with more than 1000 files, partitioning is still recommended (Basin SQL features changelog).
Basin Pipelines basin-catalog sink: Parquet roll interval
Section titled “Basin Pipelines basin-catalog sink: Parquet roll interval”Basin Pipelines can sink to Basin Catalog with --type basin-catalog (legacy r2-data-catalog). The sink creates namespace/table if missing and cannot target an existing Iceberg table.
Basin Catalog sinks only support Parquet format. JSON format is not supported for Iceberg tables.
The minimum interval for Basin Catalog sinks is 60 seconds to prevent compaction issues.
— Cloudflare, Basin Catalog sink
Default roll interval is 300 seconds; compression options include zstd (default), snappy, gzip, lz4, and uncompressed. Auth: catalog token with R2 Admin Read & Write. Walkthrough: Basin Pipelines getting started and end-to-end pipeline tutorial.
Table maintenance: compaction, manifest optimization, snapshot expiration
Section titled “Table maintenance: compaction, manifest optimization, snapshot expiration”Automatic maintenance reduces small-file overhead and old snapshot metadata. Compaction merges small Parquet files; manifest optimization (with compaction) rewrites manifests by partition when useful (manifest optimization changelog).
Compaction is the process of taking a group of small files and combining them into fewer larger files.
— Cloudflare, Data catalog compaction
Wrangler compaction enable: catalog-wide vs one table
Section titled “Wrangler compaction enable: catalog-wide vs one table”Catalog-level compaction needs a service token (--token). Table-level enable can target one namespace/table.
wrangler basin catalog compaction enable my-bucket --token <TOKEN>wrangler basin catalog compaction enable my-bucket my-namespace my-table --target-size 256wrangler basin catalog compaction disable my-bucketTarget file size is typically tuned between 64 MB and 512 MB (dashboard default often 128 MB). Compaction currently applies to Parquet data files only; orphan files not referenced by snapshots are not auto-cleaned. See Table maintenance and Wrangler commands (R2).
Snapshot expiration: age, retain count, and data file cleanup
Section titled “Snapshot expiration: age, retain count, and data file cleanup”Snapshots accumulate metadata and storage cost. Policies use --older-than-days and --retain-last; both conditions must be satisfied to expire a snapshot.
Snapshot expiration now handles both metadata and data file cleanup automatically. When a snapshot is expired, any data files that are no longer referenced by retained snapshots are removed from R2 storage.
— Cloudflare, Snapshot expiration data cleanup
Snapshot expiration is free; compaction is billed when enabled (Basin Catalog pricing).
wrangler basin catalog snapshot-expiration enable <BUCKET_NAME>wrangler basin catalog snapshot-expiration disable <BUCKET_NAME>The dashboard Maintenance tab shows schedules, queued compaction, and errors such as executor conflict or daily request limits (table maintenance dashboard changelog).
Delete Iceberg data: catalog transactions vs manual R2 delete
Section titled “Delete Iceberg data: catalog transactions vs manual R2 delete”Iceberg changes must go through the catalog, not by deleting R2 objects in the console or S3 API.
Deleting data from Basin Catalog or any Apache Iceberg catalog requires that operations are done in a transaction through the catalog itself.
— Cloudflare, Deleting data
Manually adding, modifying, or deleting objects outside the catalog can leave pointers referencing files that no longer exist, corrupting the table into an inconsistent state that is difficult to recover from.
— Cloudflare, Delete warnings changelog
Use engine DELETE FROM, DROP TABLE (files may remain), or DROP TABLE ... PURGE (irreversible). Reclaim space with snapshot expiration and compaction. Copy-on-write vs merge-on-read behaviour affects when bytes leave R2—see Deleting data.
Common mistakes
Section titled “Common mistakes”- Manual R2 deletes on catalog-enabled buckets.
- Object-only API tokens for REST catalog access.
- Read-only catalog token with read-write storage (vended writers).
- Basin Catalog sink aimed at an existing table, or JSON instead of Parquet.
- Pipeline roll interval under 60 seconds.
DROP TABLEwithout understanding thatPURGEcannot be undone.
Monitor catalog metrics and pricing dimensions
Section titled “Monitor catalog metrics and pricing dimensions”Per-catalog dashboard charts cover bytes/files compacted, catalog requests, storage size, and snapshots expired. The GraphQL Analytics API exposes datasets such as r2CatalogDataOperationsAdaptiveGroups and r2CatalogTableMaintenanceAdaptiveGroups—see Metrics.
Catalog operations (REST metadata calls) are priced separately from compaction (billed on data and objects processed when compaction is on). Retained data still incurs storage charges after snapshot expiration.
How to check this on your site
Section titled “How to check this on your site”-
Run
wrangler basin catalog get <BUCKET_NAME>and confirm the catalog is enabled and note the warehouse name (Wrangler commands (R2)). -
In the Cloudflare dashboard Basin Catalog Explorer, confirm namespaces and tables match what engines should see (Manage catalogs).
-
Run
wrangler basin sql query <WAREHOUSE_NAME> "SHOW TABLES IN <NAMESPACE>"or aLIMIT 10select (Wrangler commands (Basin SQL)). -
If you use Trino, start the container with the catalog mount and run
SHOW SCHEMAS IN r2;(Trino config example). -
Review the Maintenance tab and Metrics for compaction and snapshot expiration activity (Table maintenance, Metrics).
-
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”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, and we will correct or clarify it.