duckdb.bend relies on unsafe/foreign
raw source on the hub · import bend-data-duckdb@0.1.0.0/duckdb.bend as Duckdb
Native DuckDB driver for Bend via libduckdb (dlopen).
Public types: F32Table, TextTable. Public defs: query_f32, query_text, exec.
All query_* defs open file paths with access_mode=READ_ONLY (and open ":memory:" or "" as an in-memory database, which can also read Parquet, CSV, and JSON files via DuckDB table functions).
Numeric results return Bend's reusable List<&2, List<&2, F32>> row-major
layout with SQL NULL mapped to IEEE-754 NaN, matching bend-quant's Panel
and Mat representation with zero copying.
1 import
import Base
Types
type F32Table source · line 16 · raw
Data
Row-major F32 query result (SQL NULL -> NaN), with column names.
F32Table@rows:U32 -> @cols:U32 -> @names:List<&2, String> -> @data:List<&2, List<&2, F32>> -> F32Table
type TextTable source · line 20 · raw
Data
Row-major String query result (SQL NULL -> ""), with column names.
TextTable@rows:U32 -> @cols:U32 -> @names:List<&2, String> -> @data:List<&2, List<&2, String>> -> TextTable
Definitions
def wrap.f32 source · line 42 · raw
@r:Result<&1, &1, Pair(U32, String), Pair(U32, Pair(U32, Pair(List<&2, String>, List<&2, List<&2, F32>>)))> -> Result<&1, &1, Pair(U32, String), F32Table>
def wrap.text source · line 50 · raw
@r:Result<&1, &1, Pair(U32, String), Pair(U32, Pair(U32, Pair(List<&2, String>, List<&2, List<&2, String>>)))> -> Result<&1, &1, Pair(U32, String), TextTable>
def query_f32 source · line 64 · raw
@db_path:String -> @sql:String -> IO(Result<&1, &1, Pair(U32, String), F32Table>)
Executes a SQL query returning numeric columns as a row-major F32Table. SQL NULL values become NaN; non-numeric columns fail with EINVAL. File databases are opened with access_mode=READ_ONLY (protecting the opened database file; DuckDB SQL can still COPY TO or ATTACH external files).
def query_text source · line 73 · raw
@db_path:String -> @sql:String -> IO(Result<&1, &1, Pair(U32, String), TextTable>)
Executes a SQL query returning columns formatted as Strings (SQL NULL -> ""). Types libduckdb can't format (UUID, TIMESTAMPTZ, ENUM, nested, ...) fail with EINVAL. Cast them with ::VARCHAR. File databases are opened with access_mode=READ_ONLY.
def exec source · line 80 · raw
@db_path:String -> @sql:String -> IO(Result<&1, &1, Pair(U32, String), Unit>)
Executes one or more SQL statements in read-write mode (DDL, INSERT, COPY, etc.). Each call opens and closes the database, so ":memory:" state does not persist across calls.
Effects (foreign code)
effect raw.query_f32 source · line 25 · raw
@db_path:String -> @sql:String -> IO(Result<&1, &1, Pair(U32, String), Pair(U32, Pair(U32, Pair(List<&2, String>, List<&2, List<&2, F32>>)))>)
foreign: duckdb.c, duckdb.js
effect raw.query_text source · line 30 · raw
@db_path:String -> @sql:String -> IO(Result<&1, &1, Pair(U32, String), Pair(U32, Pair(U32, Pair(List<&2, String>, List<&2, List<&2, String>>)))>)
foreign: duckdb.c, duckdb.js
effect raw.exec source · line 35 · raw
@db_path:String -> @sql:String -> IO(Result<&1, &1, Pair(U32, String), Unit>)
foreign: duckdb.c, duckdb.js