Skip to content

Commit 8f1ebc3

Browse files
authored
Updated r2 data catalog duckdb docs to address duckdb iceberg write support and httpfs extension (#25544)
1 parent 87423e8 commit 8f1ebc3

File tree

1 file changed

+15
-4
lines changed
  • src/content/docs/r2/data-catalog/config-examples

1 file changed

+15
-4
lines changed

src/content/docs/r2/data-catalog/config-examples/duckdb.mdx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ title: DuckDB
33
pcx_content_type: example
44
---
55

6-
Below is an example of using [DuckDB](https://duckdb.org/) to connect to R2 Data Catalog (read-only). For more information on connecting to R2 Data Catalog with DuckDB, refer to [DuckDB documentation](https://duckdb.org/docs/stable/core_extensions/iceberg/iceberg_rest_catalogs#r2-catalog).
6+
Below is an example of using [DuckDB](https://duckdb.org/) to connect to R2 Data Catalog. For more information on connecting to R2 Data Catalog with DuckDB, refer to [DuckDB documentation](https://duckdb.org/docs/stable/core_extensions/iceberg/iceberg_rest_catalogs#r2-catalog).
77

88
## Prerequisites
99

1010
- Sign up for a [Cloudflare account](https://dash.cloudflare.com/sign-up/workers-and-pages).
1111
- [Create an R2 bucket](/r2/buckets/create-buckets/) and [enable the data catalog](/r2/data-catalog/manage-catalogs/#enable-r2-data-catalog-on-a-bucket).
1212
- [Create an R2 API token](/r2/api/tokens/) with both [R2 and data catalog permissions](/r2/api/tokens/#permissions).
1313
- Install [DuckDB](https://duckdb.org/docs/installation/).
14-
- Note: [DuckDB 1.3.0](https://github.com/duckdb/duckdb/releases/tag/v1.3.0) or greater is required to attach [Iceberg REST Catalogs](https://duckdb.org/docs/stable/core_extensions/iceberg/iceberg_rest_catalogs).
14+
- Note: [DuckDB 1.4.0](https://github.com/duckdb/duckdb/releases/tag/v1.4.0) or greater is required to attach and write to [Iceberg REST Catalogs](https://duckdb.org/docs/stable/core_extensions/iceberg/iceberg_rest_catalogs).
1515

1616
## Example usage
1717

@@ -22,21 +22,32 @@ In the [DuckDB CLI](https://duckdb.org/docs/stable/clients/cli/overview.html) (C
2222
INSTALL iceberg;
2323
LOAD iceberg;
2424

25+
-- Install and load httpfs extension for reading/writing files over HTTP(S).
26+
INSTALL httpfs;
27+
LOAD httpfs;
28+
2529
-- Create a DuckDB secret to store R2 Data Catalog credentials.
2630
CREATE SECRET r2_secret (
2731
TYPE ICEBERG,
2832
TOKEN '<token>'
2933
);
3034

31-
-- Attach R2 Data Catalog with the following ATTACH statement (read-only).
35+
-- Attach R2 Data Catalog with the following ATTACH statement.
3236
ATTACH '<warehouse_name>' AS my_r2_catalog (
3337
TYPE ICEBERG,
3438
ENDPOINT '<catalog_uri>'
3539
);
3640

41+
-- Create the default schema in the catalog and set it as the active schema.
42+
CREATE SCHEMA my_r2_catalog.default;
43+
USE my_r2_catalog.default;
44+
45+
-- Create and populate a sample Iceberg table with data.
46+
CREATE TABLE my_iceberg_table AS SELECT a FROM range(4) t(a);
47+
3748
-- Show all available tables.
3849
SHOW ALL TABLES;
3950

40-
-- Query your Iceberg table.
51+
-- Query the Iceberg table you just created.
4152
SELECT * FROM my_r2_catalog.default.my_iceberg_table;
4253
```

0 commit comments

Comments
 (0)