Skip to content
Skills Library
Data & analytics · Learning & explanation

duckdb

/duckdb

DuckDB engine knowledge for driving it from Rust through better-duck: the SQL dialect, the DuckDB type system and how each type maps to driver values, extensions (json, parquet, icu, spatial), and runtime behaviors (transactions, appender semantics, named/positional parameters, replacement scans). Use when writing SQL for DuckDB, choosing or reasoning about a DuckDB column type, loading an extension, or diagnosing DuckDB-specific behavior seen through the better-duck driver.

Repository
better-duck ↗
Licence
MIT
Last repository change
11.10.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 11.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

DuckDB engine knowledge for driving it from Rust through better-duck: the SQL dialect, the DuckDB type system and how each type maps to driver values, extensions (json, parquet, icu, spatial), and runtime behaviors (transactions, appender semantics, named/positional parameters, replacement scans). Use when writing SQL for DuckDB, choosing or reasoning about a DuckDB column type, loading an extension, or diagnosing DuckDB-specific behavior seen through the better-duck driver.

Original author description

DuckDB engine knowledge for driving it from Rust through better-duck: the SQL dialect, the DuckDB type system and how each type maps to driver values, extensions (json, parquet, icu, spatial), and runtime behaviors (transactions, appender semantics, named/positional parameters, replacement scans). Use when writing SQL for DuckDB, choosing or reasoning about a DuckDB column type, loading an extension, or diagnosing DuckDB-specific behavior seen through the better-duck driver.

How it works

  1. SQL dialect — the parts that surprise people
  2. Type system → driver values
  3. NULL and validity
  4. Extensions
  5. Transactions
  6. Appender semantics
  7. Diagnosing engine errors
  8. Versioning
Original SKILL.md headings · 84 lines, 604 words
SKILL.md preview
---
name: duckdb
description: >-
  DuckDB engine knowledge for driving it from Rust through better-duck: the SQL dialect, the DuckDB
  type system and how each type maps to driver values, extensions (json, parquet, icu, spatial),
  and runtime behaviors (transactions, appender semantics, named/positional parameters, replacement
  scans). Use when writing SQL for DuckDB, choosing or reasoning about a DuckDB column type, loading
  an extension, or diagnosing DuckDB-specific behavior seen through the better-duck driver.
license: MIT OR Apache-2.0
metadata:
  author: Hamid Reza Shakibi
  version: "0.1.0"
---

# DuckDB (for better-duck users)

DuckDB is an in-process OLAP SQL engine. `better-duck` embeds it and talks to its C API. This skill
covers the engine behaviors that matter when you drive it from Rust; for the Rust API itself see the
`better-duck-core` skill.

## SQL dialect — the parts that surprise people

- **PostgreSQL-like**, with analytics extras: `QUALIFY`, `GROUP BY ALL`, `SELECT * EXCLUDE (col)`,
  `SELECT * REPLACE (expr AS col)`, `COLUMNS(...)`, list/struct/map literals, `UNNEST`, window
  functions, `PIVOT`/`UNPIVOT`.
- **Friendly casting**: `CAST(x AS t)` or `x::t`. `TRY_CAST` yields NULL instead of erroring.
- **Parameters**: positional `$1, $2, …` or `?`; named `$name`. better-duck binds positional with
  `execute_with` and named with `execute_with_named`.
- **Statements**: `execute_batch` runs multiple `;`-separated statements; a single `execute`
  prepares one statement. DDL and `INSERT`/`UPDATE`/`DELETE` report a changed-row count; `SELECT`
  and `RETURNING` yield rows.
- **Replacement scans** let a bare identifier in `FROM` resolve to a registered source (e.g. an
  Arrow/Polars view, or a Rust replacement scan) — how `query_polars`/`register_arrow` surface data.

## Type system → driver values

DuckDB values arrive as `better_duck_core::types::value::DuckValue`. Core mappings:

| DuckDB type | DuckValue / Rust | Notes |
|---|---|---|
| BOOLEAN | `Boolean` / `bool` | |
| TINYINT…BIGINT | `TinyInt`/`SmallInt`/`Int`/`BigInt` (`i8`..`i64`) | |
| UTINYINT…UBIGINT | `UTinyInt`..`UBigInt` (`u8`..`u64`) | |
| HUGEINT / UHUGEINT | `HugeInt`(`i128`) / `UHugeInt`(`u128`) | 128-bit via DuckDB hugeint |
| FLOAT / DOUBLE | `Float`(`f32`) / `Double`(`f64`) | |
| DECIMAL(w,s) | `rust_decimal::Decimal` | feature `decimal`; preserves width/scale |
| VARCHAR | `Text(String)` | |
| BLOB / BIT | `Blob` / bit types | |
| DATE/TIME/TIMESTAMP[TZ]/INTERVAL | `chrono` types | feature `chrono` (or `time` feature) |
| UUID | `uuid::Uuid` | feature `uuid` |
| LIST / ARRAY / STRUCT / MAP / UNION / ENUM | nested `DuckValue` / derives | see `better-duck-macros` for `DuckEnum`/`DuckStruct` |
| NULL | `DuckValue::Null` | validity tracked per row/vector |

`TableDescription` (core) reads a table's column names, types, and `DEFAULT` flags without a query.
The lossless `TypeInfo` descriptor preserves DECIMAL width/scale, ENUM dictionaries, and nesting.

## NULL and validity

NULL is first-class: a value is `DuckValue::Null`, and in columnar access a column carries a validity
bitmask (see `better-duck-core`'s `columnar` skill — `VectorRef::validity`, `VectorMut::set_null` /
`set_row_valid`). `TRY_CAST` and `Option<T>` parameters/returns propagate NULL explicitly.

## Extensions

- Bundled at build time via core features: `json`, `parquet`, `icu` (timezones/collations). These
  compile the extension into the static library — no runtime `INSTALL`/`LOAD`.
- Loaded at runtime via core's extension API (`INSTALL`/`LOAD`), e.g. **spatial** for geometry.
- Writing your own loadable extension in Rust: `#[duckdb_entrypoint]` (feature `loadable-extension`,
  experimental) — see `better-duck-macros`.

## Transactions

DuckDB has no dedicated C-API transaction entry point; better-duck drives `BEGIN`/`COMMIT`/`ROLLBACK`
via SQL. Savepoints (`SAVEPOINT`/`RELEASE`/`ROLLBACK TO`) are **not** supported. Use core's
`Connection::transaction` (closure, commits on `Ok`, rolls back on `Err`/panic) or `begin_transaction`
(RAII guard). See `better-duck-core`.

## Appender semantics

The Appender is the fast bulk-insert path (`duckdb_appender_*`). It buffers rows and flushes on
`save()`/`finish()`; a failed append/flush invalidates the appender (then only error + destroy are
legal). Column defaults can be filled with `append_default_row` / `set_chunk_default`. Details in the
`better-duck-core` skill's appender/columnar references.

## Diagnosing engine errors

better-duck surfaces DuckDB's typed error classification as `Error::Engine(EngineError { kind, message })`,
where `kind` mirrors `duckdb_error_type`. A failed `prepare`/`query` carries DuckDB's own message.
When a query "returns results" from `execute` where you expected a changed-row count (or vice versa),
check the statement type — `SELECT`/`RETURNING` vs DML.

## Versioning

DuckDB ships an every-other-version LTS cadence from 1.4 (1.4 LTS, 1.5 current, …). The C API is
specified in `api_spec/` YAML upstream with per-function `lifecycle` (stable/deprecated/unstable) +
since-version. better-duck pins a vendored DuckDB in `better-duck-sys`.

Versions

RepositoryScoreLicence
This page · nimdeveloper/better-duck90MIT
G1Joshi/Agent-Skills100MIT
chrishuffman5/domain-expert100MIT
chrishuffman5/domain-expert95MIT
chrishuffman5/domain-expert90MIT

Database snapshot: 13.11.2026 · package version 6a14eb446f7f (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 95duckdb-en
    DuckDB CLI specialist for SQL analysis, data processing and file conversion. Use for SQL queries, CSV/Parquet/JSON analysis, database queries, or data conversion. Triggers on "duckdb", "sql", "query", "data analysis", "parquet", "convert data".
  • 100duckdb-transformation
    Expert knowledge for writing, optimizing, and migrating DuckDB transformations in Keboola. Covers SQL dialect, block orchestration, dynamic backends, Parquet format, case sensitivity, Snowflake-to-DuckDB migration, type casting patterns, and best practices. Use when the user is…
  • 92write-script-duckdb
    MUST use when writing DuckDB queries.
  • 100better-duck-core
    Rust API guide for the better-duck-core crate (the embedded DuckDB driver published as better-duck): opening connections, executing SQL, iterating rows and values, parameter binding, bulk insert, columnar chunks, transactions, pooling, async, and Arrow/Polars interop. Use when…
  • 100che-duckdb-mcp
    Guide for using the che-duckdb-mcp MCP tools to search DuckDB documentation and operate local DuckDB databases. Use when user asks about DuckDB SQL syntax, DuckDB functions (read_csv, json_extract, etc.), querying local .duckdb files, or anything related to DuckDB.
  • 100duckdb-in-process-analytical-queries
    Use this skill when running vectorized in-process SQL queries directly against Parquet, Arrow, and CSV files using DuckDB.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.