跳转到内容
本站为社区维护的非官方中文翻译,与 Cloudflare, Inc. 无关联。本站不提供账户登录,请勿在任何非官方站点输入您的 Cloudflare 账户信息。官方文档:developers.cloudflare.com

DuckDB

最后更新 查看 MarkdownAgent 设置

以下示例展示如何使用 DuckDB ↗ 连接到 Basin Catalog。有关使用 DuckDB 连接 Basin Catalog 的更多信息,请参阅 DuckDB 文档 ↗。

前提条件

示例用法

在 DuckDB CLI ↗(命令行界面)中运行以下命令:

-- Install the Iceberg DuckDB extension if needed, then load the extension.
INSTALL iceberg;
LOAD iceberg;

-- Install and load httpfs extension for reading/writing files over HTTP(S).
INSTALL httpfs;
LOAD httpfs;

-- Create a DuckDB secret to store Basin Catalog credentials.
CREATE SECRET r2_secret (
    TYPE ICEBERG,
    TOKEN '<token>'
);

-- Attach Basin Catalog with the following ATTACH statement.
ATTACH '<warehouse_name>' AS my_r2_catalog (
    TYPE ICEBERG,
    ENDPOINT '<catalog_uri>'
);

-- Create the default schema in the catalog and set it as the active schema.
CREATE SCHEMA my_r2_catalog.default;
USE my_r2_catalog.default;

-- Create and populate a sample Iceberg table with data.
CREATE TABLE my_iceberg_table AS SELECT a FROM range(4) t(a);

-- Show all available tables.
SHOW ALL TABLES;

-- Query the Iceberg table you just created.
SELECT * FROM my_r2_catalog.default.my_iceberg_table;

这篇文档对您有帮助吗?