DuckDB
Query and write CSV and Parquet files in XNS storage straight from DuckDB SQL.
Overview
DuckDB is an in-process analytical database. Its httpfs extension reads and writes s3:// paths, so you can run SQL directly over CSV and Parquet files in a bucket on your Relayer and write query results back to it. You connect DuckDB to the Relayer with an S3 secret that sets the endpoint, path-style URLs and whether to use TLS.
Tested with DuckDB 1.5.6 on 2026-10-18 against Relayer build 59a37e64.
Each run, over HTTP on port 9000 and over HTTPS on port 9443, wrote a 2-million-row table to the bucket as CSV, as a Parquet file and as a Hive-partitioned Parquet dataset (97 files). It read each one back, found zero differing rows, listed the dataset with a glob, and checked the CSV’s SHA-256 against a local copy (106 MB). It then deleted the files.
Connect to XNS
Every S3 tool connects to your Relayer with the same settings. Enter them exactly as shown; the notes below the table cover the two that most tools get wrong by default.
| Setting | Value |
|---|---|
| Endpoint (HTTP) | http://<relayer-host>:9000, where <relayer-host> is the address of the machine running your Relayer. Always available. |
| Endpoint (HTTPS) | https://<relayer-host>:9443, available only after a certificate is installed on the Relayer. Port 9000 never serves HTTPS. |
| Region | us-east-1 |
| Addressing | Path-style. In tools that ask, turn on force path style or path-style access, and turn off virtual-hosted style. |
| Signature | Signature Version 4 (V4). Version 2 is refused. |
| Access key and secret key | For a tool, create a scoped key: IAM → Create IAM User in the Relayer UI. The secret is shown once, so copy it then. The install’s root pair is on Configure → Credentials; keep it for administration. |
| Bucket | Create it first: Files → Create Bucket in the Relayer UI, or let the tool create it. Names are 3-63 characters of lowercase letters, digits, hyphens and periods. |
HTTPS and certificates. The Relayer UI offers two certificates for port 9443: Let’s Encrypt, which needs a domain managed in Cloudflare and a Cloudflare API token, or self-signed. Most tools refuse a self-signed certificate unless certificate verification is turned off in the tool. On a private network, plain HTTP on port 9000 avoids the question.
Path-style. A tool left on virtual-hosted style (often labeled Amazon S3 or AWS) sends the bucket name in the hostname, and the Relayer cannot find the bucket. Choose the tool’s S3 compatible or generic S3 option and set path-style.
Not supported: server-side encryption with customer-provided keys (SSE-C) or KMS keys (SSE-KMS), bucket website hosting and bucket replication. Server-side encryption with AES256 is accepted. See Encryption at the Gateway, Identity and Access and Configure.
Prerequisites
- DuckDB 1.5 or later (install). The
httpfsandawsextensions download on first use. - A bucket and a scoped key on your Relayer (see the table above). A key with the ReadWrite policy is enough.
Step 1: Create the secret
The ENDPOINT is host and port only, with no http://. Set USE_SSL false for port 9000.
INSTALL httpfs; LOAD httpfs;
CREATE OR REPLACE SECRET xns (
TYPE s3,
KEY_ID '<access key>',
SECRET '<secret key>',
ENDPOINT '<relayer-host>:9000',
URL_STYLE 'path',
USE_SSL false,
REGION 'us-east-1'
);For HTTPS, use ENDPOINT '<relayer-host>:9443' and USE_SSL true.
To keep the key out of your SQL, read it from an AWS profile in ~/.aws/credentials instead:
INSTALL aws; LOAD aws;
CREATE OR REPLACE SECRET xns (
TYPE s3,
PROVIDER credential_chain,
CHAIN 'config',
PROFILE 'xns',
ENDPOINT '<relayer-host>:9000',
URL_STYLE 'path',
USE_SSL false,
REGION 'us-east-1'
);Add PERSISTENT after CREATE OR REPLACE to keep the secret across sessions.
Step 2: Write data
COPY my_table TO 's3://<bucket>/exports/my_table.csv' (HEADER, DELIMITER ',');
COPY my_table TO 's3://<bucket>/exports/my_table.parquet' (FORMAT parquet);
COPY my_table TO 's3://<bucket>/lake/my_table' (FORMAT parquet, PARTITION_BY (region), OVERWRITE_OR_IGNORE);Step 3: Query it
SELECT count(*) FROM read_csv('s3://<bucket>/exports/my_table.csv');
SELECT * FROM 's3://<bucket>/exports/my_table.parquet' LIMIT 10;
SELECT region, sum(amount)
FROM read_parquet('s3://<bucket>/lake/my_table/*/*.parquet', hive_partitioning = true)
GROUP BY region;
SELECT * FROM glob('s3://<bucket>/lake/my_table/*/*.parquet');Known limits
URL_STYLE 'path'is required. The default,vhost, puts the bucket in the hostname, and DuckDB fails withCould not resolve hostname.USE_SSL falseis required for port 9000. The default is TLS, which fails on port 9000 withSSL connect error.- DuckDB cannot delete objects. Remove files with the Relayer UI or another S3 tool, such as the AWS CLI.
- Self-signed certificates on port 9443 were not tested; the test used a trusted certificate.
- Not supported by the Relayer: SSE-C and SSE-KMS server-side encryption.
