Pure-Go (
CGO_ENABLED=0)puregobinding for DuckDBv1.5.6with streaming-only queries, cooperative cancellation, exact SQL types (includingVARIANT), chunk-buffered bulkAppender,database/sqldriver, andCGO_ENABLED=0Apache Arrow integration.
See USAGE.md for complete code examples and DEVELOPMENT.md for architecture, testing, and upgrade workflows.
| Package | Purpose | External Dependencies |
|---|---|---|
duckdb |
Core engine API: verified Load & AutoLoad (cross-platform discovery + SHA-256-verified download), Database, InstanceCache, TaskState/ExecuteTasks, Conn, Tx, Stmt, streaming Rows/ArrowRows (multi-result-set), chunk-buffered Appender & QueryAppender (incl. GEOMETRY & VARIANT), pure-Go extensions (RegisterScalarFunction[Set], RegisterAggregateFunction[Set], RegisterCastFunction, RegisterTableFunction, RegisterCopyFunction, AddReplacementScan, RegisterLogStorage, RegisterConfigOption, RegisterLogicalType), Arrow C Data/Stream interop, Client VFS (File), Catalog metadata, BudgetController, ReadOnlySession, QueryProgress/ProfilingInfo. |
github.com/ebitengine/purego |
duckdbsql |
Full database/sql/driver adapter (NewConnector, NewReadOnlyConnector, Register, WithDBInit/WithConnInit, WithTimeScan, Composite[T], sql.Null[T] + Go []T/[N]T/map[K]V binding, driver.RowsNextResultSet, RawConn). |
duckdb (stdlib database/sql only) |
duckdbarrow |
Pure-Go (CGO_ENABLED=0) apache/arrow-go/v18 integration (Query/QueryStmt/QueryScript -> array.RecordReader, StmtSchema, bidirectional ExtensionType + C Data ExportSchema/ExportRecordBatch, AppendRecordBatch/AppendRecordReader, RegisterRecordBatch/RegisterRecordReader). |
github.com/apache/arrow-go/v18 |
duckdbspike targets Go services that want zero-cgo builds (CGO_ENABLED=0), pinned & SHA-256-verified native library loading, strict streaming & memory/cancellation isolation, and full core SQL/Arrow/database/sql ergonomics without sacrificing type exactness.
| Capability | duckdb/duckdb-go/v2 (Official CGO) |
bububa/duckdbspike (CGO_ENABLED=0) |
|---|---|---|
| Build model | Requires CGO + C/C++ toolchain | Pure Go (CGO_ENABLED=0) via purego |
| Native library verification | Linked at build time | Runtime path/permission guards + SHA-256 checksum + pinned v1.5.6 version check + AutoLoad cross-platform discovery/download |
| Streaming query execution | Optional / chunk fetch | Streaming-only (duckdb_pending_prepared_streaming + duckdb_result_is_streaming == true) |
| Cooperative cancellation | duckdb_interrupt |
Latched cancellation with periodic duckdb_interrupt re-assertion & no-deadline join |
Core SQL types (38/38 runtime DUCKDB_TYPE) |
Supported | Supported (exact types, no lossy float/JSON intermediates; recursive VARIANT decoding + chunk-appender GEOMETRY/VARIANT writes) |
database/sql driver |
Built-in (Connector, Composite[T], WithBootQueries) |
duckdbsql (NewConnector, NewReadOnlyConnector, WithDBInit/WithConnInit, Composite[T], sql.Null[T], Go []T/[N]T/map[K]V, RowsNextResultSet) |
Bulk Appender & QueryAppender |
Chunk-buffered Appender + QueryAppender |
Chunk-buffered (2048-row DataChunk) AppendRow / AppendRows (incl. GEOMETRY & VARIANT), DefaultValue, AddColumn, QueryAppender |
| Apache Arrow (C Data & C Stream) | CGO arrow/cdata + Arrow / RegisterView |
Pure-Go (CGO_ENABLED=0) duckdbarrow: full Arrow C Data (incl. ExtensionType) + streaming duckdb_arrow_scan + multi-result-set ArrowRows |
Client VFS (duckdb_file_system_*) & Catalog |
Not exposed in Go API | Conn.OpenFile (io.ReadWriteSeeker) & CatalogTypeName/LookupCatalogEntry |
External Threading (duckdb_execute_tasks*) |
Not exposed in Go API | Database.ExecuteTasks & Database.NewTaskState (*TaskState) with UAF-safe shutdown join |
| Resource budgeting & read-only isolation | Manual SQL / OS limits | Built-in BudgetController, DecodeLimits/ResultLimits, and ReadOnlySession |
| Extensions & Engine Hooks (UDFs/Table/Copy/Cast) | Supported (Scalar/Aggregate/Table/Copy/ReplacementScan) | Full (CGO_ENABLED=0): RegisterScalarFunction[Set], RegisterAggregateFunction[Set], RegisterCastFunction, RegisterTableFunction, RegisterCopyFunction (COPY TO/FROM), AddReplacementScan, RegisterLogStorage, RegisterConfigOption, RegisterLogicalType |
Please review these explicit boundaries before adopting duckdbspike:
- Intentionally Disallowed Native Paths:
- Non-streaming queries (
duckdb_pending_prepared) are never used;Queryalways enforces streaming results (ErrNotStreamingif DuckDB materializes a result such asINSERT ... RETURNING). - Lossy numeric C helpers (
duckdb_decimal_to_double,duckdb_hugeint_to_double, etc.) are never used; all exact numeric values stay lossless. - Library unloading (
dlclose/FreeLibrary) is never called; mapped libraries live for the process lifetime.
- Non-streaming queries (
- DuckDB
v1.5.6Upstream C API Boundaries:GEOMETRYandVARIANTprepared-statement parameter binding: DuckDBv1.5.6C API does not provideduckdb_create_geometryorduckdb_create_variantconstructors. Both types support full decoding and bulk chunkAppender/QueryAppenderwrites, while direct SQL parameter binding returnsErrUnsupportedType(use SQL casts such asST_GeomFromWKB(?::BLOB)/CAST(? AS VARIANT)orNewQueryAppender).duckdb_arrow_scan/duckdb_arrow_array_scanprojection-pushdown quirk: In DuckDBv1.5.6, querying a registered Arrow view while skipping leading columns (e.g.SELECT col2 FROM arrow_view) can crash inside DuckDB's C++FactoryGetNext. Project all columns from Arrow views, or ingest into a temporary table viaduckdbarrow.AppendRecordReaderfor arbitrary column projections.
- Platform Gate (
darwin/amd64unsupported):- Only platforms with recorded real-native acceptance runs are allowed at load time (
darwin/arm64,linux/amd64,linux/arm64,windows/amd64). Unverified platforms fail withErrUnsupportedPlatform.
- Only platforms with recorded real-native acceptance runs are allowed at load time (
| Platform | Status | Artifact | SHA-256 (shared library) | License |
|---|---|---|---|---|
darwin/arm64 |
Accepted (real native verified) | DuckDB v1.5.6 (libduckdb-osx-universal.zip) |
75a519cb914ae36ca22cff0995a8a2e8c9a46990b8c0a479514f741a0d93f344 |
MIT |
linux/amd64 |
Accepted (real native verified) | DuckDB v1.5.6 (libduckdb-linux-amd64.zip) |
3f4962cdd266eab2b479a5b5a4a6d063d279b2954ae814ed00385d553b747633 |
MIT |
linux/arm64 |
Accepted (real native verified) | DuckDB v1.5.6 (libduckdb-linux-arm64.zip) |
23686593dba4ec22c6e581bb1c843b3964e84c4bc4d0063d8b4daddd2e20e30a |
MIT |
windows/amd64 |
Accepted (real native verified) | DuckDB v1.5.6 (libduckdb-windows-amd64.zip) |
7e90bdef028d57b45490d6f53530e3c012a5d9abdc4c6723449200663dc84ed0 |
MIT |
darwin/amd64 |
Unsupported (unverified) | — | — | — |
Platforms without a real native acceptance record are rejected at load time with ErrUnsupportedPlatform. Cross-compilation is not acceptance.
- Streaming only:
Queryusesduckdb_pending_prepared_streaming(isolated ininternal/abi, pinned tov1.5.6) and assertsduckdb_result_is_streaming == true. - Exact types & owned Go memory: Signed/unsigned integers, 128-bit
Hugeint/Uhugeint, all four physical widths ofDecimal,Varchar/Blob/Bit/Bignum/UUID/Enum/Geometry, unit-preserving temporal types (including±infinity),List/Array/Struct/Map/Union, and recursiveVARIANTvalues are decoded into Go-owned memory that never aliases native buffers. Unsupported logical types fail at prepare/result inspection even when all rows areNULLor empty. - Cooperative native cancellation & no-deadline join: Cancellation latches and re-asserts
duckdb_interrupt(surviving DuckDB'sInitialCleanupinterrupt reset) until the native scope exits.Rows.Close,ArrowRows.Close,Conn.Close, andDatabase.Closeinterrupt in-flight work and join all native calls and cancel executors before releasing or reusing handles. - Read-only session isolation:
SessionWorkspace.OpenReadOnlyseals input Parquet files and the temporary catalog read-only, checkpoints and closes the write instance, reopensREAD_ONLY, and appliesallowed_paths,enable_external_access=false, andlock_configuration=true. Two DuckDB engine residuals remain (CREATE TEMP TABLEin memory andCOPY TO spill/), soReadOnlySessionis intended for trusted, parameterized internal query templates.
- USAGE.md — Practical examples for
duckdb,duckdbsql,duckdbarrow,Appender,VARIANT, Client VFS,Catalog,BudgetController, andReadOnlySession. - DEVELOPMENT.md — Repository layout, build/test commands, CI matrix, and
abi.PinnedVersionupgrade procedure.
Upgrading abi.PinnedVersion requires re-running the full real-native matrix on every accepted platform:
DUCKDB_HEADER_DIR=/path/to/headers \
DUCKDB_LIB_PATH=/path/to/libduckdb.dylib \
DUCKDB_LIB_SHA256=<sha256> \
CGO_ENABLED=0 go test -count=1 ./...
DUCKDB_HEADER_DIR=/path/to/headers \
DUCKDB_LIB_PATH=/path/to/libduckdb.dylib \
DUCKDB_LIB_SHA256=<sha256> \
go test -race -count=1 ./...