Skip to content

Repository files navigation

Query.Farm

DuckDB ADBC Extension (adbc)

DuckDB v1.5 build

Query Snowflake, PostgreSQL, MySQL, Trino, Microsoft SQL Server, Apache DataFusion, Arrow Flight SQL, and any other system with an ADBC driver directly from DuckDB.

The extension registers as adbc_scanner internally; its functions and the ATTACH ... (TYPE adbc) storage type are exposed under the adbc name.

Documentation

Full documentation, including installation, driver setup, the ATTACH storage layer, the function reference, secrets, connection profiles, and cookbook examples, is available at:

https://query.farm/products/extensions/adbc_scanner

Installation

INSTALL adbc_scanner FROM community;
LOAD adbc_scanner;

Runtime command API (breaking change)

This source version removes scalar remote commands. Use CALL for execution, transactions, disconnecting, and cache clearing:

SET VARIABLE conn = (SELECT adbc_connect({'driver': 'sqlite', 'uri': 'shared.sqlite'}));
CALL adbc_execute(getvariable('conn')::BIGINT, 'CREATE TABLE IF NOT EXISTS messages (id INTEGER, body TEXT)');
CALL adbc_execute(getvariable('conn')::BIGINT, 'INSERT INTO messages VALUES (1, ''hello'')');
SELECT * FROM adbc_scan_table(getvariable('conn')::BIGINT, 'messages');
SELECT * FROM adbc_scan(getvariable('conn')::BIGINT,
    'SELECT id, body FROM messages WHERE id = ?', params := row(1),
    columns := {'id': 'BIGINT', 'body': 'VARCHAR'});
CALL adbc_disconnect(getvariable('conn')::BIGINT);

EXPLAIN and PREPARE do not execute these commands. EXPLAIN ANALYZE does execute them. adbc_execute returns one rows_affected value, or SQL NULL if the driver does not supply a count. The former SELECT adbc_execute(...) syntax is rejected. The community package must be updated before these examples apply to INSTALL ... FROM community.

Query binding uses ADBC schema metadata only. Drivers such as SQLite that cannot describe arbitrary queries without executing them require columns := {...}. adbc_scan_table uses table metadata. Returned column counts and types are checked against the bound schema before Arrow data is read.

See the migration guide for transactions, connection ownership, typed options, and driver limitations.

Development

For instructions on building the extension from source and running its tests, see docs/BUILDING.md.

About

A DuckDB ADBC Scanner Extension - adds support for using ADBC drivers with DuckDB as a client.

Topics

Resources

Stars

25 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages