You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/r2/data-catalog/config-examples/duckdb.mdx
+15-4Lines changed: 15 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,15 +3,15 @@ title: DuckDB
3
3
pcx_content_type: example
4
4
---
5
5
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).
7
7
8
8
## Prerequisites
9
9
10
10
- Sign up for a [Cloudflare account](https://dash.cloudflare.com/sign-up/workers-and-pages).
11
11
-[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).
12
12
-[Create an R2 API token](/r2/api/tokens/) with both [R2 and data catalog permissions](/r2/api/tokens/#permissions).
- 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).
15
15
16
16
## Example usage
17
17
@@ -22,21 +22,32 @@ In the [DuckDB CLI](https://duckdb.org/docs/stable/clients/cli/overview.html) (C
22
22
INSTALL iceberg;
23
23
LOAD iceberg;
24
24
25
+
-- Install and load httpfs extension for reading/writing files over HTTP(S).
26
+
INSTALL httpfs;
27
+
LOAD httpfs;
28
+
25
29
-- Create a DuckDB secret to store R2 Data Catalog credentials.
26
30
CREATE SECRET r2_secret (
27
31
TYPE ICEBERG,
28
32
TOKEN '<token>'
29
33
);
30
34
31
-
-- Attach R2 Data Catalog with the following ATTACH statement (read-only).
35
+
-- Attach R2 Data Catalog with the following ATTACH statement.
32
36
ATTACH '<warehouse_name>'AS my_r2_catalog (
33
37
TYPE ICEBERG,
34
38
ENDPOINT '<catalog_uri>'
35
39
);
36
40
41
+
-- Create the default schema in the catalog and set it as the active schema.
42
+
CREATESCHEMAmy_r2_catalog.default;
43
+
USE my_r2_catalog.default;
44
+
45
+
-- Create and populate a sample Iceberg table with data.
46
+
CREATETABLEmy_iceberg_tableASSELECT a FROM range(4) t(a);
0 commit comments