Repository navigation
Everything C API v2! #27525
Replies: 7 comments 15 replies
|
There are some thing we know we already want/need to change that could be good to be aware of Remove
|
Rework/fix expressions and table-filter-pushdownThe V2-C-API adds basic read-only introspection of some of DuckDBs bound expressions, which is currently only used to support filter-pushdown for table functions. These are currently very much borked with multiple known defects, e.g. #25391, #27475. Part of the complexity here is trying to make a simpler and "generic" interface that can handle all of DuckDBs complex expression types without completely blowing up the API surface - while we at the same time are actively trying to rework and simplify how we represent different expressions in core (#24008, #22490) . There are also other small ergonomic issues in this part of the API, e.g. getting the qualified name from a function expression performs an allocation/requires destroying the qname handle, not all function properties can be inspected, etc. I don't really have anything concrete to say here more than: we know filter-pushdown is important, we want to expose a small but powerful expression API for both inspecting/creating expressions, we're actively working on making changes in core DuckDB to streamline this, this part of the API will likely change significantly before being stabilized. One way I kind of envision this to eventually look like is having a set of "leaf" expression types (constants, column refs), and a small set of "special forms", e.g. |
PHP-PDO has an inTransaction method (see https://www.php.net/manual/en/pdo.intransaction.php), currently I'm implementing: |
For unwrapping variants, I'm currently using VariantValue::GetValue(). |
|
I have experimented with using zig 0.17 to build an extension using comptime wrappers for the C API v 1 and v 2 (preview) using a fork of the "zig-duckdb-ext" repo and wonder how to use "table in-out functions" with the C API v 2? |
|
Thanks for putting this together. A stable ABI would make a huge difference for us, so I'm happy to give detailed feedback. Some background: at Query.Farm we maintain around 45 community extensions (airport, adbc_scanner, datasketches, crypto, httpserver, tributary, radio, redis, shellfs, quickjs, a5, geosilo and a bunch more). Right now every one of them gets rebuilt for every DuckDB release on v1.4, v1.5 and v2.0. I went through each extension and checked what it uses from DuckDB internals against The good news first. The simple scalar/aggregate extensions (crypto, hashfuncs, bitfilters, datasketches, rapidfuzz, tsid, marisa, lindel, etc.) look like a fairly mechanical port. A few things I really like:
Now the stuff that blocks us, roughly in order of how many extensions it hits. Running SQL / getting an instance from extension code. This is the big one. Callbacks get a This blocks cronjob (scheduler thread runs queries), httpserver (runs queries on server threads), webmacro, quackscale and radio. tributary also logs from librdkafka callback threads, and Related to this, we'd need:
Secrets. There's no secrets API at all. redis, tributary, openprompt, airport and adbc_scanner all register secret types and look secrets up. We could switch to settings or named parameters, but users already have secrets set up so that would be a step backwards for them. HTTP. No access to Storage/catalog extensions. airport and adbc_scanner are built on Table functions.
Types.
Missing extension points.
Smaller things.
VGI. Our biggest extension is vgi, which exposes scalar, table, aggregate, table in-out and COPY functions implemented by remote workers (subprocess, HTTP, unix sockets, containers, Iroh, and in the browser under WASM), with data moving over Arrow IPC. It also ATTACHes remote catalogs. It's a good test of how far v2 can go, and right now only around 10-15% of it could move: the diagnostic table functions, global settings, logging, file I/O for the result cache, and Arrow conversion for the basic types. Beyond everything above, it would need:
A few questions:
On
And +1 on dropping If it helps, we're happy to port a few of the simpler extensions (crypto, hashfuncs, and datasketches, which is code-generated so it's a decent stress test) to v2 + |
Works:
Improvements/features:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi there, beloved community :-)
We are proud to announce the 2nd version of our C API, completely rewritten with the goal to provide you with a single API to build your extensions and clients with. This API is available in experimental mode starting with v2.0.0, and we need you to help us work towards stabilizing it. We'd love to do this over the course of DuckDB's v2 line, in small pieces. With stabilization of the API come guarantees: extensions and clients that are built on stabilized symbols only will not have to recompile across minor and patch releases. DuckDB guarantees a stable ABI and your binaries will Just Keep Working ™️.
In this discussion we want to ask you for any and all feedback you have. What works? What doesn't? Which features do you need us to add? Also tell us about your experience with the C++ API we built on top of it (
duckdb::cxx/ duckdb_cpp.hpp), or about the new Rust bindings.A few notes: It's totally fine to link your bug reports and issues here as well if they contribute to the discussion. But please do not report them here, or use this forum as a place to make them visible. Also note our community discord channel, which is most suitable for getting community support around specific questions you may have.
All reactions