### Full example: setup, cache, and query
Source: https://duckdb.org/community_extensions/extensions/ducksync
Shows installation, attaching an existing DuckLake catalog or full setup, registering a Snowflake source, creating a cache with TTL, and querying via ducksync functions.
```SQL
-- Install and load the extension
INSTALL ducksync FROM community;
LOAD ducksync;
```
```SQL
-- Option A: Use an existing DuckLake catalog
ATTACH 'ducklake:postgres:host=localhost dbname=ducklake user=postgres password=secret' AS my_lake (DATA_PATH '/data');
SELECT * FROM ducksync_init('my_lake');
```
```SQL
-- Option B: Full setup (attaches DuckLake automatically)
SELECT * FROM ducksync_setup_storage(
'host=localhost port=5432 dbname=ducklake user=postgres password=secret',
'/data/ducksync'
);
```
```SQL
-- Register Snowflake source (requires existing DuckDB secret)
SELECT * FROM ducksync_add_source('prod', 'snowflake', 'my_snowflake_secret');
```
```SQL
-- Create a cache with 1-hour TTL
SELECT * FROM ducksync_create_cache(
'customers_cache',
'prod',
'SELECT * FROM PROD.PUBLIC.CUSTOMERS',
['PROD.PUBLIC.CUSTOMERS'],
3600
);
```
```SQL
-- Query via smart routing (cache hit or passthrough)
SELECT * FROM ducksync_refresh('customers_cache');
```
```SQL
-- Query via smart routing: cache hit → DuckLake, miss → Snowflake passthrough
SELECT * FROM ducksync_query(
'SELECT * FROM PROD.PUBLIC.CUSTOMERS WHERE region = ''US''',
'prod'
);
```
```SQL
-- Or query the DuckLake table directly
SELECT * FROM ducksync.prod.customers_cache;
```
--------------------------------
### Quick Start: Build Tiles and Route
Source: https://duckdb.org/community_extensions/extensions/valhalla_routing
Quick start example that builds tiles from a URL, loads them, and performs a simple route calculation.
```sql
-- Build tiles from HTTP URL
SELECT valhalla_build_tiles(
'https://download.geofabrik.de/europe/monaco-latest.osm.pbf',
'./tiles'
);
-- Load and route
SET valhalla_tiles = './tiles';
SELECT valhalla_route(ST_Point(7.42, 43.73), ST_Point(7.43, 43.74), 'auto');
```
--------------------------------
### Full Example: Install, Create Secret, Query and Attach Snowflake
Source: https://duckdb.org/community_extensions/extensions/snowflake
Complete example showing installation, creation of a Snowflake secret with password authentication, querying via snowflake_query(), and attaching the database for direct SQL access. Includes comments explaining each step.
```sql
-- Install and load the extension
INSTALL snowflake FROM community;
LOAD snowflake;
-- Create a Snowflake secret with password authentication
CREATE SECRET my_snowflake (
TYPE snowflake,
ACCOUNT 'your-account',
USER 'your-username',
PASSWORD 'your-password',
DATABASE 'your-database'
);
-- Query Snowflake data using pass-through query function
SELECT * FROM snowflake_query(
'SELECT * FROM customers WHERE state = ''CA''',
'my_snowflake'
);
-- Attach Snowflake database for direct SQL access
ATTACH '' AS sf (TYPE snowflake, SECRET my_snowflake, READ_ONLY);
SELECT * FROM sf.schema.customers WHERE state = 'CA';
```
--------------------------------
### Full Routing Example with valhalla_build_tiles and valhalla_route
Source: https://duckdb.org/community_extensions/extensions/valhalla_routing
Complete example showing how to install required extensions, build tiles from a PBF URL, load them, and calculate a route with distance, duration, and waypoint count.
```sql
-- Load extensions
INSTALL httpfs; LOAD httpfs;
INSTALL spatial; LOAD spatial;
LOAD valhalla_routing;
-- Download and build tiles (Pure SQL!)
SELECT valhalla_build_tiles(
'https://download.geofabrik.de/europe/monaco-latest.osm.pbf',
'./monaco_tiles'
);
-- Load tiles
SET valhalla_tiles = './monaco_tiles';
-- Calculate route
SELECT
round(r.distance_km, 1) as km,
round(r.duration_minutes, 1) as minutes,
ST_NPoints(r.geometry) as waypoints
FROM (
SELECT valhalla_route(
ST_Point(7.4275, 43.7397), -- Casino Monte-Carlo
ST_Point(7.4254, 43.7308), -- Oceanographic Museum
'auto'
) as r
);
```
--------------------------------
### Install and load huggingface extension
Source: https://duckdb.org/community_extensions/extensions/huggingface
Installs and loads the huggingface extension from the community repository. The example repeats the same commands in the next snippet, but here they are shown as the installation and loading step.
```sql
INSTALL huggingface FROM community;
LOAD huggingface;
```
--------------------------------
### Install and load the zim extension
Source: https://duckdb.org/community_extensions/extensions/zim
Install the extension from the community repository and load it. This is the required setup before using any zim functions.
```sql
INSTALL zim FROM community;
LOAD zim;
```
--------------------------------
### Example: read Zeek log with read_zeek
Source: https://duckdb.org/community_extensions/extensions/zeek
Shows installing, loading optional inet module, reading conn.log.gz, and filtering by service.
```sql
INSTALL zeek FROM community;
LOAD inet; # if you want to automatically parse IPs and CIDRs.
LOAD zeek;
-- Read a Zeek log file (supports .gz compression and globs)
SELECT * FROM read_zeek('conn.log.gz');
-- Filter by service
SELECT ts, id_orig_h, id_resp_h, service
FROM read_zeek('conn.log.gz')
WHERE service = 'http';
```
--------------------------------
### Example usage of protoduck
Source: https://duckdb.org/community_extensions/extensions/protoduck
Shows how to install and load protoduck, register a protobuf schema at runtime with proto_schema_add, decode a BLOB to JSON with proto_to_json, and extract a field with proto_get.
```sql
INSTALL protoduck FROM community;
LOAD protoduck;
-- Register a protobuf schema at runtime
SELECT proto_schema_add('
syntax = "proto3";
package demo;
message Person {
string name = 1;
int32 age = 2;
}
');
-- Decode a protobuf BLOB to JSON
SELECT proto_to_json(data, 'demo.Person') FROM people;
-- Extract a single field via dot-notation path
SELECT proto_get(data, 'demo.Person', 'name') FROM people;
```
--------------------------------
### Example: fin_bsm_price and fin_simple_return
Source: https://duckdb.org/community_extensions/extensions/finance
Example usage of the finance extension: installs and loads it, then computes a Black-Scholes-Merton call option price and a simple return. The output is not shown in the source.
```sql
INSTALL finance FROM community;
LOAD finance;
SELECT
fin_bsm_price('call', 100.0, 100.0, 1.0, 0.05, 0.20) AS price,
fin_simple_return(105.0, 100.0) AS simple_return;
```
--------------------------------
### Installing and loading the zeek extension
Source: https://duckdb.org/community_extensions/extensions/zeek
Use INSTALL and LOAD commands to install and load the extension from the community repository.
```sql
INSTALL zeek FROM community;
LOAD zeek;
```
--------------------------------
### Install and load query_limiter
Source: https://duckdb.org/community_extensions/extensions/query_limiter
Use INSTALL and LOAD commands to install the extension from the community repository and load it into a session. These commands must be run before using the extension's settings.
```sql
INSTALL query_limiter FROM community;
LOAD query_limiter;
```
--------------------------------
### Install and load the extension
Source: https://duckdb.org/community_extensions/extensions/ducksync
Install ducksync from the community repository and load it.
```SQL
INSTALL ducksync FROM community;
LOAD ducksync;
```
--------------------------------
### INSTALL and LOAD table_guard
Source: https://duckdb.org/community_extensions/extensions/table_guard
Use the `INSTALL` command to install the table_guard extension from the community repository, then `LOAD` it to activate the extension in the current session.
```sql
INSTALL table_guard FROM community;
LOAD table_guard;
```
--------------------------------
### BoilStream end-to-end example with OPAQUE login, bootstrap session, and secrets
Source: https://duckdb.org/community_extensions/extensions/boilstream
Complete example workflow covering extension setup, authentication (email/password/MFA and bootstrap token), listing ducklakes and secrets, creating a ducklake, querying an attached ducklake, and creating a persistent S3 secret on the BoilStream server. The output tables for each query are shown as displayed. Note: clean up ~/.duckdb/history after login to avoid saving credentials.
```sql
-- Setup: Install and load boilstream extension
INSTALL httpfs; LOAD httpfs;
INSTALL boilstream FROM community;
LOAD boilstream;
-- Option 1: Login with email/password/MFA (establishes OPAQUE session)
-- NOTE: Remember to clean up your ~/.duckdb/history
PRAGMA boilstream_login('https://api.example.com/user@example.com', 'password', '123456');
┌────────────────────────┬─────────────────────┬────────────────────┐
│ status │ expires_at │ ducklakes_attached │
├────────────────────────┼─────────────────────┼────────────────────┤
│ Session token obtained │ 2025-11-21 10:30:00 │ 2 │
└────────────────────────┴─────────────────────┴────────────────────┘
-- Option 2: Authenticate with bootstrap token (from SSO/web UI)
PRAGMA boilstream_bootstrap_session('https://api.example.com/secrets:TOKEN');
┌────────────────────────┬─────────────────────┬────────────────────┐
│ status │ expires_at │ ducklakes_attached │
├────────────────────────┼─────────────────────┼────────────────────┤
│ Session token obtained │ 2025-11-21 10:30:00 │ 2 │
└────────────────────────┴─────────────────────┴────────────────────┘
-- List all available ducklakes
FROM boilstream_ducklakes();
┌──────────────┬──────────────┬─────────────────┐
│ catalog_id │ catalog_name │ description │
├──────────────┼──────────────┼─────────────────┤
│ 5a805647-... │ my_analytics │ Sales analytics │
└──────────────┴──────────────┴─────────────────┘
-- List all cached secrets with expiration
FROM boilstream_secrets();
┌─────────────────────┬──────────┬─────────────────────┐
│ name │ type │ expires_at │
├─────────────────────┼──────────┼─────────────────────┤
│ my_analytics │ ducklake │ 2026-11-19 20:00:00 │
│ my_analytics_s3 │ s3 │ 2026-11-19 20:00:00 │
│ my_analytics_pg │ postgres │ 2026-11-19 20:00:00 │
└─────────────────────┴──────────┴─────────────────────┘
-- Create new ducklake
PRAGMA boilstream_create_ducklake('new_catalog', 'My new ducklake');
-- Query ducklake (automatically attached)
USE my_analytics;
SHOW TABLES;
-- Create persistent secret onto BoilStream server
CREATE PERSISTENT SECRET s3_minio IN boilstream (
TYPE S3,
KEY_ID 'minioadmin',
SECRET 'minioadmin',
REGION 'eu-west-1',
ENDPOINT 'localhost:9000',
USE_SSL false,
URL_STYLE 'path',
SCOPE 's3://ingestion-data/'
);
```
--------------------------------
### Installing and Loading
Source: https://duckdb.org/community_extensions/extensions/bigquery
Commands to install and load the bigquery extension.
```APIDOC
## INSTALL bigquery FROM community;
### Description
Installs the bigquery extension from the community repository.
### Method
INSTALL
### Endpoint
INSTALL bigquery FROM community;
### Parameters
None
### Request Example
INSTALL bigquery FROM community;
### Response
No response body.
```
```APIDOC
## LOAD bigquery;
### Description
Loads the bigquery extension into the current DuckDB session.
### Method
LOAD
### Endpoint
LOAD bigquery;
### Parameters
None
### Request Example
LOAD bigquery;
### Response
No response body.
```
--------------------------------
### Binomial distribution function examples
Source: https://duckdb.org/community_extensions/extensions/stochastic
Examples of calling binomial distribution functions with parameters (10, 0.5) and optional x value.
```sql
dist_binomial_cdf(10, 0.5, 5)
```
```sql
dist_binomial_cdf_complement(10, 0.5, 5)
```
```sql
dist_binomial_chf(10, 0.5, 5)
```
```sql
dist_binomial_hazard(10, 0.5, 5)
```
```sql
dist_binomial_kurtosis(10, 0.5)
```
```sql
dist_binomial_kurtosis_excess(10, 0.5)
```
```sql
dist_binomial_log_cdf(10, 0.5, 5)
```
--------------------------------
### Install and load the stochastic extension
Source: https://duckdb.org/community_extensions/extensions/stochastic
Install the stochastic extension from the community repository and load it into the current DuckDB session. Must be executed before using any of the distribution functions provided by the extension.
```sql
INSTALL stochastic FROM community;
LOAD stochastic;
```
--------------------------------
### Beta distribution function examples
Source: https://duckdb.org/community_extensions/extensions/stochastic
Examples of calling beta distribution functions with parameters (2.0, 5.0) and optional x or p values.
```sql
dist_beta_cdf_complement(2.0, 5.0, 0.5)
```
```sql
dist_beta_chf(2.0, 5.0, 0.5)
```
```sql
dist_beta_hazard(2.0, 5.0, 0.5)
```
```sql
dist_beta_kurtosis(2.0, 5.0)
```
```sql
dist_beta_kurtosis_excess(2.0, 5.0)
```
```sql
dist_beta_log_cdf(2.0, 5.0, 0.5)
```
```sql
dist_beta_log_cdf_complement(2.0, 5.0, 0.5)
```
```sql
dist_beta_log_pdf(2.0, 5.0, 0.5)
```
```sql
dist_beta_mean(2.0, 5.0)
```
```sql
dist_beta_median(2.0, 5.0)
```
```sql
dist_beta_mode(2.0, 5.0)
```
```sql
dist_beta_pdf(2.0, 5.0, 0.5)
```
```sql
dist_beta_quantile(2.0, 5.0, 0.95)
```
```sql
dist_beta_quantile_complement(2.0, 5.0, 0.05)
```
```sql
dist_beta_range(2.0, 5.0)
```
```sql
dist_beta_sample(2.0, 5.0)
```
```sql
dist_beta_skewness(2.0, 5.0)
```
```sql
dist_beta_stddev(2.0, 5.0)
```
```sql
dist_beta_support(2.0, 5.0)
```
```sql
dist_beta_variance(2.0, 5.0)
```
--------------------------------
### ai_prep_search example
Source: https://duckdb.org/community_extensions/extensions/ai
Creates retrieval and context-enriched embedding chunks from text or Markdown. Example: SELECT * FROM ai_prep_search('# Guide
DuckDB runs in process.', title := 'Guide');
```sql
SELECT * FROM ai_prep_search('# Guide
DuckDB runs in process.', title := 'Guide');
```
--------------------------------
### Get Example Phone Number
Source: https://duckdb.org/community_extensions/extensions/anofox_tabular
Returns an example valid phone number for the given 2-letter ISO region code (e.g., 'US'). The example uses 'US'.
```sql
SELECT phonenumber_example('US');
```
--------------------------------
### quackapi example: create routes and serve
Source: https://duckdb.org/community_extensions/extensions/quackapi
Complete example showing how to create JSON, HTML, and POST endpoints with CREATE ROUTE, serve them with quackapi_serve, and manage with quackapi_routes and quackapi_stop. Includes curl examples for testing.
```sql
LOAD quackapi;
-- JSON endpoint: the SELECT is the handler
CREATE ROUTE hello GET '/hello' AS SELECT 'world' AS msg;
-- Path params bind as $id; cast failure → FastAPI-shaped 422
CREATE ROUTE item GET '/items/:id' AS SELECT $id::INTEGER AS id;
-- HTML when the single output column is named html
CREATE ROUTE home GET '/' AS SELECT '
quackapi
' AS html;
-- Typed optional query param with constraint
CREATE ROUTE search GET '/search'
PARAM limit INTEGER DEFAULT 10 LE 100
AS
SELECT $q::VARCHAR AS q, $limit::INTEGER AS limit;
-- POST mutation (JSON body fields bind as $name / $age)
CREATE ROUTE create_user POST '/users' STATUS 201 AS
SELECT $name::VARCHAR AS name, $age::INTEGER AS age;
-- Serve (background threads; shell stays usable)
-- Optional: static_dir for unrouted GETs; cors_origins for browser CORS
SELECT * FROM quackapi_serve(8000, static_dir := './static');
-- curl http://127.0.0.1:8000/hello → [{"msg":"world"}]
-- curl http://127.0.0.1:8000/items/42 → [{"id":42}]
-- curl http://127.0.0.1:8000/items/abc → 422 detail[loc=path,id]
-- curl -X POST …/users -H 'Content-Type: application/json' -d '{"name":"a","age":3}'
SELECT * FROM quackapi_routes();
SELECT * FROM quackapi_stop(8000);
```
--------------------------------
### Example: Get observefs profile
Source: https://duckdb.org/community_extensions/extensions/observefs
Copies the result of the observefs_get_profile() function to a file. This example shows how to retrieve the profile data.
```sql
COPY (SELECT observefs_get_profile()) TO '/tmp/output.txt';
```
--------------------------------
### Install and load finetype
Source: https://duckdb.org/community_extensions/extensions/finetype
Install the extension from the community repository and load it into the session.
```sql
INSTALL finetype FROM community;
LOAD finetype;
```
--------------------------------
### INSTALL pst FROM community; LOAD pst;
Source: https://duckdb.org/community_extensions/extensions/pst
Install and load the pst extension.
```APIDOC
## INSTALL pst FROM community; LOAD pst;
### Description
Install and load the pst extension.
### Method
INSTALL
### Endpoint
INSTALL pst FROM community;
LOAD pst;
### Request Example
```sql
INSTALL pst FROM community;
LOAD pst;
```
```
--------------------------------
### Example: opt_pack_best_of and opt_knapsack_exact
Source: https://duckdb.org/community_extensions/extensions/anofox_optimize
Shows how to use opt_pack_best_of and opt_knapsack_exact on sample data. opt_pack_best_of runs every packing algorithm and returns the fewest bins used; opt_knapsack_exact finds the perfect subset-sum fill that greedy rules miss.
```sql
-- Cartons waiting to ship, and a container that holds 1000 units.
CREATE TABLE cartons AS SELECT * FROM VALUES
(1, 420.0), (2, 380.0), (3, 260.0), (4, 240.0),
(5, 190.0), (6, 180.0), (7, 150.0), (8, 130.0)
AS t(carton_id, size);
-- How few containers hold everything? `best_of` runs every packing
-- algorithm in the family and returns whichever used the fewest bins.
SELECT opt_pack_best_of(list(size ORDER BY carton_id), 1000.0).bins_used AS containers
FROM cartons;
-- Which shipments go on a cheaper carrier that only takes 1000 units?
-- Value == weight, so this is subset-sum, and `exact` finds the perfect
-- fill that greedy rules miss.
SELECT opt_knapsack_exact(
list(weight ORDER BY shipment_id),
list(weight ORDER BY shipment_id),
1000.0
).total_weight AS loaded_on_cheap_carrier
FROM (VALUES (1, 505.0), (2, 380.0), (3, 260.0), (4, 240.0), (5, 115.0))
AS s(shipment_id, weight);
```
--------------------------------
### Install and load marc21 extension
Source: https://duckdb.org/community_extensions/extensions/marc21
Required setup before using any marc21 functions. Install the extension from the community repository and load it into the current session.
```sql
INSTALL marc21 FROM community;
LOAD marc21;
```
--------------------------------
### Inspect Optimized Plans and Enable Round-Trip Checking
Source: https://duckdb.org/community_extensions/extensions/lpts
Examples demonstrating how to set dialects, generate SQL from logical plans using PRAGMA and EXPLAIN, and enable transparent round-trip validation.
```sql
-- Set both input and output dialects to DuckDB for a first round trip.
D SET lpts_input_dialect = 'duckdb';
D SET lpts_dialect = 'duckdb';
D CREATE TABLE users (id INTEGER, name VARCHAR, age INTEGER);
D INSERT INTO users VALUES (1, 'Alice', 30), (2, 'Bob', 22), (3, 'Carol', 28);
-- Return the optimized plan as readable CTE SQL.
D PRAGMA lpts('SELECT name FROM users WHERE age > 25');
WITH
t0_scan (t0_name) AS (
SELECT "name"
FROM memory.main.users
WHERE (age>25)
)
SELECT t0_name AS "name"
FROM t0_scan;
-- The same output, exposed as a first-class EXPLAIN statement.
D EXPLAIN (FORMAT SQL) SELECT name FROM users WHERE age > 25;
┌─────────────────────────────┐
│┌───────────────────────────┐│
││ Optimized Logical Plan ││
│└───────────────────────────┘│
└─────────────────────────────┘
WITH
t0_scan (t0_name) AS (
SELECT "name"
FROM memory.main.users
WHERE (age>25)
)
SELECT t0_name AS "name"
FROM t0_scan;
-- Turn on transparent round-trip checking. Every top-level SELECT is now
-- rewritten by LPTS and its result compared against the original; a wrong
-- rewrite raises an error. The query otherwise returns its normal rows.
D SET lpts_check = true;
D SELECT name FROM users WHERE age > 25;
┌─────────┐
│ name │
│ varchar │
├─────────┤
│ Alice │
│ Carol │
└─────────┘
```
--------------------------------
### Install and load duck_dggs from community
Source: https://duckdb.org/community_extensions/extensions/duck_dggs
Installs the duck_dggs extension from the community repository and loads it into the session. This is the required setup before using any DGGS functions.
```sql
INSTALL duck_dggs FROM community;
LOAD duck_dggs;
```
--------------------------------
### Install and load delta_classic from community
Source: https://duckdb.org/community_extensions/extensions/delta_classic
Install the extension from the community repository and load it. Required before using the ATTACH command.
```sql
INSTALL delta_classic FROM community;
LOAD delta_classic;
```
--------------------------------
### Install and load duckgql extension
Source: https://duckdb.org/community_extensions/extensions/duckgql
Installs the duckgql extension from the community repository and loads it into DuckDB. This is the required setup before using any DuckGQL functionality.
```sql
INSTALL duckgql FROM community;
LOAD duckgql;
```
--------------------------------
### Install and load curl_httpfs extension
Source: https://duckdb.org/community_extensions/extensions/curl_httpfs
Installs and loads the curl_httpfs extension from the community repository. This is the required setup before using the extension's functions.
```sql
INSTALL curl_httpfs FROM community;
LOAD curl_httpfs;
```
--------------------------------
### Install and load QuickJS extension
Source: https://duckdb.org/community_extensions/extensions/quickjs
Installs and loads the QuickJS extension from the community repository.
```sql
INSTALL quickjs FROM community;
LOAD quickjs;
```
--------------------------------
### duckrouting example: shortest path, driving distance, version
Source: https://duckdb.org/community_extensions/extensions/duckrouting
Example showing graph setup with an edges table and usage of duckrouting_dijkstra, duckrouting_driving_distance, and duckrouting_version.
```sql
INSTALL duckrouting FROM community;
LOAD duckrouting;
-- Any table with an id, two endpoints and a cost is a graph. No topology
-- tables to build, no geometry required.
CREATE TABLE edges (
id BIGINT, source BIGINT, target BIGINT, cost DOUBLE, reverse_cost DOUBLE
);
INSERT INTO edges VALUES
(1, 5, 6, 1, 1), (2, 6, 10, -1, 1), (3, 10, 15, -1, 1), (4, 6, 7, 1, 1);
-- Shortest path from vertex 5 to vertex 7
SELECT node, edge, agg_cost FROM duckrouting_dijkstra(
'SELECT id, source, target, cost, reverse_cost FROM edges', 5, 7);
-- node | edge | agg_cost
-- 5 | 1 | 0.0
-- 6 | 4 | 1.0
-- 7 | -1 | 2.0
-- Everything within a cost radius: the service area around a point
SELECT node, agg_cost FROM duckrouting_driving_distance(
'SELECT id, source, target, cost, reverse_cost FROM edges', 6, 2.0);
SELECT duckrouting_version('hello');
```
--------------------------------
### Install and load observefs
Source: https://duckdb.org/community_extensions/extensions/observefs
Install the observefs extension from the community repository and load it. This is required before using any observefs functions.
```sql
INSTALL observefs FROM community;
LOAD observefs;
```
--------------------------------
### Install and load mssql_ducklake
Source: https://duckdb.org/community_extensions/extensions/mssql_ducklake
Installs and loads the mssql_ducklake extension from the community repository. This is the standard setup step before using any DuckLake functionality with a SQL Server catalog.
```sql
INSTALL mssql_ducklake FROM community;
LOAD mssql_ducklake;
```
--------------------------------
### Example: Connect to Keboola Storage and perform operations
Source: https://duckdb.org/community_extensions/extensions/keboola
Shows how to attach to Keboola Storage, read and write data, and use secrets for credential management.
```sql
-- Install and load the extension
INSTALL keboola FROM community;
LOAD keboola;
-- Connect to Keboola Storage
ATTACH 'https://connection.keboola.com' AS kbc (
TYPE keboola,
TOKEN 'my-storage-api-token'
);
-- Read data
SELECT * FROM kbc."in.c-crm".contacts WHERE status = 'active';
-- Write data
INSERT INTO kbc."in.c-crm".contacts VALUES ('42', 'Alice', 'alice@acme.com');
-- Use secrets for credential management
CREATE SECRET my_kbc (
TYPE keboola,
TOKEN 'my-storage-api-token',
URL 'https://connection.keboola.com'
);
ATTACH '' AS kbc2 (TYPE keboola, SECRET my_kbc);
```
--------------------------------
### Install and load otlp extension
Source: https://duckdb.org/community_extensions/extensions/otlp
Install the extension from the community repository and load it.
```sql
INSTALL otlp FROM community;
LOAD otlp;
```
--------------------------------
### onager_sub_k_hop example
Source: https://duckdb.org/community_extensions/extensions/onager
Returns nodes within k hops from a start node, returning node_id.
```sql
select * from onager_sub_k_hop((select src, dst from edges_table), start := 1, k := 2);
```
--------------------------------
### Install and load qvd extension
Source: https://duckdb.org/community_extensions/extensions/qvd
Install the qvd extension from the community repository and load it.
```sql
INSTALL qvd FROM community;
LOAD qvd;
```
--------------------------------
### Complete Usage Example for duckdb_delta_sharing
Source: https://duckdb.org/community_extensions/extensions/duckdb_delta_sharing
A comprehensive example covering installation, loading, network access, secret configuration, discovering shares, reading tables, time travel, and change data feed.
```sql
INSTALL duckdb_delta_sharing FROM community;
LOAD duckdb_delta_sharing;
-- Required for network access
INSTALL httpfs;
LOAD httpfs;
-- Basic Configuration
-- Set your sharing endpoint and bearer token using DuckDB Secrets:
CREATE SECRET (
TYPE delta_sharing,
PROVIDER config,
ENDPOINT 'https://your-delta-sharing-server.com/api/2.0/delta-sharing',
BEARER_TOKEN 'your_private_token'
);
-- Alternatively, if you have DELTA_SHARING_ENDPOINT and DELTA_SHARING_BEARER_TOKEN set in your environment:
CREATE SECRET (TYPE delta_sharing, PROVIDER env);
-- Discovering Content
SELECT * FROM delta_share_list(); -- shares
SELECT * FROM delta_share_list('my_share'); -- schemas in a share
SELECT * FROM delta_share_list('my_share', 'my_schema'); -- tables in a schema
SELECT * FROM delta_share_list_all_tables('my_share'); -- every table across all schemas
SELECT * FROM delta_share_list('my_share', 'my_schema', 'my_table');-- a table's columns
-- Reading Tables
SELECT * FROM delta_share_read('my_share', 'my_schema', 'my_table')
WHERE year = 2024
LIMIT 100;
-- Time Travel
SELECT count(*)
FROM delta_share_read('my_share', 'my_schema', 'my_table', '2024-04-09 12:00:00');
-- Change Data Feed (CDF)
SELECT *
FROM delta_share_change_data_feed('my_share', 'my_schema', 'my_table', 10);
```
--------------------------------
### duckorch Orchestration Example
Source: https://duckdb.org/community_extensions/extensions/duckorch
Complete example showing initialization, task registration, DAG execution, asset management, dynamic asset creation, sensor, lineage, and JSON ingestion. Requires a directory of *.sql task files and an 'orders.jsonl' file or HTTP endpoint.
```sql
LOAD duckorch;
-- 1. Set up state schema and register a directory of *.sql task files.
PRAGMA orch_init;
PRAGMA orch_register('./tasks/');
-- 2. Run the DAG (topological order, per-layer parallelism).
SET orch_max_parallel = 4;
PRAGMA orch_run;
-- 3. Asset-aware features (Phase 13+):
PRAGMA orch_asset_list; -- all registered Assets
PRAGMA orch_asset_partitions('analytics.daily'); -- per-partition status
PRAGMA orch_backfill('analytics.daily', '2026-01-01', '2026-12-31');
-- 4. Snowflake-compatible declaration (Phase 17):
PRAGMA orch_create_dynamic_asset(
'analytics.region_total',
'5 minutes',
'SELECT region, SUM(total) AS rt FROM analytics.daily GROUP BY region');
-- 5. Sensor — auto-materializes when upstream updates (Phase 15):
PRAGMA orch_sensor_set_interval(30);
PRAGMA orch_sensor_start;
-- 6. Mermaid lineage:
PRAGMA orch_visualize('lineage');
-- 7. JSON ingestion (Phase 19): nested JSON becomes flat parent/child
-- tables, and later-arriving columns are absorbed automatically.
PRAGMA orch_ingest_preview('orders.jsonl', 'raw.orders'); -- shape only
PRAGMA orch_ingest_run('orders/*.jsonl', 'raw.orders');
PRAGMA orch_ingest_run('orders.jsonl', 'raw.orders',
disposition = 'merge', primary_key = 'id');
PRAGMA orch_ingest_http('https://api.example.com/orders', 'raw.orders',
secret = 'orders_api', paginate = 'cursor',
records_path = 'data', cursor_path = 'meta.next',
cursor_param = 'cursor');
```
--------------------------------
### Whisper transcription examples
Source: https://duckdb.org/community_extensions/extensions/whisper
Example queries for the whisper extension: transcribe an audio file, get detailed segments with timestamps, and list available models. The output shows the expected result format for each query.
```sql
-- Transcribe an audio file
D SELECT whisper_transcribe('audio.wav', 'tiny.en');
┌──────────────────────────────────────────────────┐
│ whisper_transcribe(...) │
│ varchar │
├──────────────────────────────────────────────────┤
│ Hello, this is a test of the whisper extension. │
└──────────────────────────────────────────────────┘
-- Get detailed transcription segments with timestamps
D SELECT * FROM whisper_transcribe_segments('audio.wav', 'tiny.en');
┌────────────┬────────────┬──────────┬────────────────────┬────────────┬──────────┐
│ segment_id │ start_time │ end_time │ text │ confidence │ language │
│ int32 │ double │ double │ varchar │ double │ varchar │
├────────────┼────────────┼──────────┼────────────────────┼────────────┼──────────┤
│ 0 │ 0.00 │ 2.50 │ Hello, this is a │ 0.95 │ en │
│ 1 │ 2.50 │ 4.00 │ test of whisper. │ 0.92 │ en │
└────────────┴────────────┴──────────┴────────────────────┴────────────┴──────────┘
-- List available models
D SELECT model_name, size_mb, is_downloaded FROM whisper_list_models() LIMIT 3;
┌────────────┬─────────┬───────────────┐
│ model_name │ size_mb │ is_downloaded │
│ varchar │ int64 │ boolean │
├────────────┼─────────┼───────────────┤
│ tiny │ 75 │ false │
│ tiny.en │ 75 │ true │
│ base │ 142 │ false │
└────────────┴─────────┴───────────────┘
```
--------------------------------
### Get extension version with gaggle_version
Source: https://duckdb.org/community_extensions/extensions/gaggle
Returns the extension version string, for example "0.1.0".
```sql
select gaggle_version();
```
--------------------------------
### Installation and Loading
Source: https://duckdb.org/community_extensions/extensions/cloudwatch
Commands to install and load the cloudwatch extension from the community repository.
```sql
INSTALL cloudwatch FROM community;
LOAD cloudwatch;
```
--------------------------------
### Redis Extension Usage Examples
Source: https://duckdb.org/community_extensions/extensions/redis
Examples of creating local and cloud Redis connection secrets, and performing Redis operations: set, get, hash set/get, list push, list range, and bulk push.
```sql
-- Create a local Redis connection secret
CREATE SECRET IF NOT EXISTS redis (
TYPE redis,
PROVIDER config,
host 'localhost',
port '6379',
password 'optional_password'
);
-- Create a Redis cloud connection secret
CREATE SECRET IF NOT EXISTS redis (
TYPE redis,
PROVIDER config,
host 'redis-1234.ec2.redns.redis-cloud.com',
port '16959',
password 'xxxxxx'
);
-- Set a value
SELECT redis_set('user:1', 'John Doe', 'redis') as result;
-- Get a value
SELECT redis_get('user:1', 'redis') as user_name;
-- Set hash fields
SELECT redis_hset('user:1', 'email', 'john@example.com', 'redis');
SELECT redis_hset('user:1', 'age', '30', 'redis');
-- Get hash field
SELECT redis_hget('user:1', 'email', 'redis') as email;
-- Push items to list
SELECT redis_lpush('mylist', 'first_item', 'redis');
SELECT redis_lpush('mylist', 'second_item', 'redis');
-- Get range from list (returns comma-separated values)
-- Get all items (0 to -1 means start to end)
SELECT redis_lrange('mylist', 0, -1, 'redis') as items;
-- Get first 5 items
SELECT redis_lrange('mylist', 0, 4, 'redis') as items;
-- Push multiple items
WITH items(value) AS (
VALUES ('item1'), ('item2'), ('item3')
)
SELECT redis_lpush('mylist', value, 'redis')
FROM items;
```
--------------------------------
### http_get Example with JSON Parsing
Source: https://duckdb.org/community_extensions/extensions/http_client
Example using http_get to perform a GET request to httpbin.org, then parse the response body with from_json to extract the Host header. The result table shows the status, reason, and host.
```SQL
-- GET Request Example w/ JSON Parsing
WITH __input AS (
SELECT
http_get(
'https://httpbin.org/delay/0',
headers => MAP {
'accept': 'application/json',
},
params => MAP {
'limit': 1
}
) AS res
),
__response AS (
SELECT
(res->>'status')::INT AS status,
(res->>'reason') AS reason,
unnest( from_json(((res->>'body')::JSON)->'headers', '{"Host": "VARCHAR"}') ) AS features
FROM
__input
)
SELECT
__response.status,
__response.reason,
__response.Host AS host
FROM
__response
;
```
```text
┌────────┬─────────┬─────────────┐
│ status │ reason │ host │
│ int32 │ varchar │ varchar │
├────────┼─────────┼─────────────┤
│ 200 │ OK │ httpbin.org │
└────────┴─────────┴─────────────┘
```
--------------------------------
### dns_lookup_all: forward DNS lookup all records examples
Source: https://duckdb.org/community_extensions/extensions/dns
Shows how to use dns_lookup_all to retrieve all IPv4 addresses or all records of a specified type (MX, TXT) as a VARCHAR array. Includes an example of unnesting the array to get individual records.
```sql
-- Get all IPv4 addresses (default behavior)
SELECT dns_lookup_all('cloudflare.com');
-- Returns: [104.16.132.229, 104.16.133.229] (or similar)
-- Get all MX records
SELECT dns_lookup_all('google.com', 'MX');
-- Returns: [10 smtp.google.com.]
-- Get all TXT records
SELECT dns_lookup_all('google.com', 'TXT');
-- Returns: [v=spf1 include:_spf.google.com ~all, google-site-verification=..., ...]
-- Unnest to get individual records
SELECT unnest(dns_lookup_all('google.com', 'TXT')) as txt_record;
```
--------------------------------
### Example: Privacy Setup and Noised Aggregation with TPC-H
Source: https://duckdb.org/community_extensions/extensions/pac
Complete example showing how to generate TPC-H data, mark a privacy unit, protect sensitive columns, define join chains, and run an aggregate query that is automatically noised.
```sql
-- Generate TPC-H benchmark data
INSTALL tpch;
LOAD tpch;
CALL dbgen(sf=1);
-- Mark customer as the privacy unit
ALTER TABLE customer ADD PAC_KEY (c_custkey);
ALTER TABLE customer SET PU;
-- Protect sensitive customer columns
ALTER PU TABLE customer ADD PROTECTED (c_custkey);
ALTER PU TABLE customer ADD PROTECTED (c_name);
ALTER PU TABLE customer ADD PROTECTED (c_address);
ALTER PU TABLE customer ADD PROTECTED (c_acctbal);
-- Define join chain: lineitem -> orders -> customer
ALTER TABLE orders ADD PAC_LINK (o_custkey) REFERENCES customer(c_custkey);
ALTER TABLE lineitem ADD PAC_LINK (l_orderkey) REFERENCES orders(o_orderkey);
-- Aggregates on linked tables are automatically noised
SELECT l_returnflag, l_linestatus, SUM(l_extendedprice)
FROM lineitem GROUP BY ALL;
```
--------------------------------
### Example: Configure and Run Queries with DuckLineage
Source: https://duckdb.org/community_extensions/extensions/duck_lineage
Configure the OpenLineage backend URL and run queries. Lineage is captured automatically without query changes. The example creates tables and a derived table, then selects from it, streaming START/COMPLETE events with lineage details to the backend.
```sql
-- Point DuckLineage at a running OpenLineage backend (e.g. Marquez at localhost:5000)
SET duck_lineage_url = 'http://localhost:5000/api/v1/lineage';
-- SET duck_lineage_namespace = 'my-data-warehouse';
-- SET duck_lineage_api_key = 'your-api-key';
-- SET duck_lineage_debug = true;
-- Run any query — lineage is captured automatically, no query changes required.
CREATE TABLE greetings (id INTEGER, message VARCHAR);
INSERT INTO greetings VALUES (1, 'Hello'), (2, 'World');
-- Derived table — column-level lineage links shouted.message -> greetings.message.
CREATE TABLE shouted AS
SELECT id, upper(message) AS message FROM greetings;
SELECT * FROM shouted;
-- START/COMPLETE events with input/output datasets, schemas, column-level lineage,
-- SQL facet, and row-count statistics are streamed to the OpenLineage backend.
```
--------------------------------
### Get Phone Number Module Status
Source: https://duckdb.org/community_extensions/extensions/anofox_tabular
Returns the current configuration and status of the phone number module. The example retrieves the status.
```sql
SELECT * FROM phonenumber_status();
```
--------------------------------
### Install and load parser_tools extension
Source: https://duckdb.org/community_extensions/extensions/parser_tools
Install the extension from the community repository and load it into the session.
```sql
INSTALL parser_tools FROM community;
LOAD parser_tools;
```
--------------------------------
### onager_apx_tsp example
Source: https://duckdb.org/community_extensions/extensions/onager
Returns a greedy approximate TSP tour with order and node_id. Accepts weighted edges and an optional start node.
```sql
select * from onager_apx_tsp((select src, dst, weight from edges_table), start := 1);
```
--------------------------------
### Install and load storage_compat
Source: https://duckdb.org/community_extensions/extensions/storage_compat
Installs and loads the storage_compat extension from the community repository. Required before using the storage_compat: prefix.
```sql
INSTALL storage_compat FROM community;
LOAD storage_compat;
```
--------------------------------
### Embed strings with subtoken_embed and check truncation
Source: https://duckdb.org/community_extensions/extensions/subtoken
Shows how to use subtoken_embed to get a 256-dimensional vector for each row, how it composes with WHERE and LIMIT, how to detect truncation with subtoken_is_truncated, and how to get version info with subtoken_version. The example creates a sample table and runs several queries.
```sql
-- A vector for a string, from a model compiled into this binary. No API
-- key, no network call, no per-row bill.
CREATE TABLE corpus (id INTEGER, description VARCHAR);
INSERT INTO corpus VALUES
(1, 'a maker of industrial fasteners'),
(2, 'a regional freight forwarder'),
(3, 'a foundry casting valve bodies'),
(4, 'a chain of hardware stores');
-- 256 floats per row, for this model.
SELECT id, len(subtoken_embed(description)) AS width FROM corpus ORDER BY id;
-- subtoken_embed is a scalar, so it composes with WHERE and LIMIT: embed a filtered
-- subset rather than a whole table.
SELECT id, subtoken_embed(description) AS v
FROM corpus
WHERE description LIKE '%valve%';
-- Long text is cut before the mean is taken, and the vector that comes back
-- is full width and unit norm either way — nothing about it says content was
-- dropped. Ask, rather than counting tokens.
SELECT count(*) AS truncated_rows
FROM corpus
WHERE subtoken_is_truncated(description);
-- Which build, which model, which width.
SELECT subtoken_version();
```
--------------------------------
### Installing and loading python_udf
Source: https://duckdb.org/community_extensions/extensions/python_udf
Install the extension from the community repository and load it. Run these commands before using any python_udf functions.
```sql
INSTALL python_udf FROM community;
LOAD python_udf;
```
--------------------------------
### Example: Read and Write mmcif Files
Source: https://duckdb.org/community_extensions/extensions/mmcif
Demonstrates reading a compressed mmcif file, attaching it as a database, querying atom data, and writing mutations back to a file.
```SQL
sql
-- single table
SELECT count(*) FROM mmcif_scan('https://files.rcsb.org/download/1AMB.cif.gz', 'atom_site');
-- 438
-- All tables in file
ATTACH 'https://files.rcsb.org/download/1AMB.cif.gz' AS mmcifdb (TYPE mmcif);
USE mmcifdb;
SELECT count(*) FROM information_schema.tables WHERE table_catalog = 'mmcifdb';
-- 43
SELECT count(*) FROM atom_site;
-- 438
-- Positions of Zinc atoms
SELECT Cartn_x, Cartn_y, Cartn_z FROM atom_site WHERE type_symbol = 'ZN';
-- Write mode
ATTACH '1amb_updated.cif' AS wdb (TYPE mmcif, READ_WRITE TRUE);
USE wdb;
BEGIN;
INSERT INTO atom_site (label_atom_id, Cartn_x, type_symbol) VALUES ('O1', 3.5, 'O');
UPDATE atom_site SET type_symbol='ZZ' WHERE label_atom_id='O1';
DELETE FROM atom_site WHERE label_atom_id='O1';
COMMIT;
-- writes the mutated tables back to the attached file
```
--------------------------------
### graph_teams_members examples
Source: https://duckdb.org/community_extensions/extensions/erpl_web
Lists all members of a Microsoft Teams team. The first argument accepts a team GUID or a displayName (resolved via /me/joinedTeams).
```SQL
SELECT * FROM graph_teams_members('Engineering', secret := 'ms_graph')
```
```SQL
SELECT * FROM graph_teams_members('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', secret := 'ms_graph')
```
--------------------------------
### graph_teams_channels examples
Source: https://duckdb.org/community_extensions/extensions/erpl_web
Lists all channels in a Microsoft Teams team. The first argument accepts a team GUID or a displayName (resolved via /me/joinedTeams).
```SQL
SELECT * FROM graph_teams_channels('Engineering', secret := 'ms_graph')
```
```SQL
SELECT * FROM graph_teams_channels('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', secret := 'ms_graph')
```
--------------------------------
### Install and load luajit extension
Source: https://duckdb.org/community_extensions/extensions/luajit
Install the luajit extension from the community repository and load it into the current session. Must be run before using any luajit functions.
```sql
INSTALL luajit FROM community;
LOAD luajit;
```