Add write support: INSERT INTO and CREATE TABLE AS for attached ADBC databases#9
Open
jatorre wants to merge 2 commits intoQuery-farm:mainfrom
Open
Add write support: INSERT INTO and CREATE TABLE AS for attached ADBC databases#9jatorre wants to merge 2 commits intoQuery-farm:mainfrom
jatorre wants to merge 2 commits intoQuery-farm:mainfrom
Conversation
…databases Implement PlanInsert and PlanCreateTableAs in AdbcCatalog, enabling: ATTACH 'driver=./my_driver.dylib&...' AS db (TYPE adbc); INSERT INTO db.my_table SELECT * FROM local_data; CREATE TABLE db.new_table AS SELECT * FROM local_data; The implementation follows the same pattern as postgres_scanner: - AdbcInsert PhysicalOperator acts as a Sink, receiving DataChunks - DataChunks are converted to Arrow batches via ArrowAppender - Batches are fed into an AdbcInsertStream (Arrow C Data Interface) - The stream is bound to an ADBC statement with BindStream() - ExecuteUpdate() sends all data to the remote database This reuses the existing adbc_insert.cpp infrastructure (AdbcInsertStream, AdbcStatementWrapper) but wires it into the DuckDB catalog planning system so that standard SQL INSERT works on attached databases. Supports ADBC ingest modes: create, append (via INSERT vs CREATE TABLE AS).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enables standard SQL INSERT and CREATE TABLE AS on attached ADBC databases:
Implementation
AdbcInsertPhysicalOperator (new): sink that converts DataChunks → Arrow → ADBC BindStreamAdbcCatalog::PlanInsertandPlanCreateTableAs: wire planning into the catalogpostgres_scanner'sPostgresInsertadbc_insert.cppinfrastructure (AdbcInsertStream, ArrowAppender)Changes
src/include/storage/adbc_insert.hpp— new AdbcInsert operator headersrc/storage/adbc_insert.cpp— new operator implementation + catalog planningsrc/storage/adbc_catalog.cpp— remove NotImplementedException stubsCMakeLists.txt— add new source fileImpact
This makes every ADBC driver writable from DuckDB — not just one database. Any driver that implements the ADBC bulk ingest interface (
Bind/BindStream+ExecuteUpdate) will work:Motivation
Currently
adbc_scanneronly supports reads viaadbc_scan(). Theadbc_insert()table function exists for programmatic writes, but standard SQL INSERT doesn't work on attached databases becausePlanInsertthrowsNotImplementedException.This was the last missing piece for using ADBC as a universal read/write connector from DuckDB SQL.
Test plan