← ClaudeAtlas

duckdb-sqllisted

Write and run DuckDB 2.0 SQL. Covers friendly SQL, lambdas, triggers, nested schemas, variables, exact decimals, and the result traps that change answers silently. Use when the user asks for a query, a trigger, a lambda, GROUP BY ALL, PIVOT, MERGE, or a SQL migration.
srimon12/duckdb-2-skills · ★ 1 · API & Backend · score 65
Install: claude install-skill srimon12/duckdb-2-skills
# DuckDB 2.0 SQL Execute statements with `duckdb`. If a session file from `duckdb-session` exists, supply it via `-init`. ## Before a large query To inspect result columns and types without executing a query, run `DESCRIBE SELECT ...`. To compute full column statistics across all rows, run `SUMMARIZE <table>`. When restricting query output, never run `LIMIT` without an explicit `ORDER BY`; unordered limits return nondeterministic rows. ## Lambdas DuckDB disables single-arrow syntax; write `lambda x: expr`. Higher-order list functions comprise `list_transform`, `list_filter`, and `list_reduce`: ```sql SELECT list_transform([1, 2, 3], lambda x: x + 1); SELECT list_transform([10, 20], lambda x, i: i); -- [1, 2], 1-based index ``` When tracking positions, use `lambda x, i:` for the element and its 1-based index. When encountering `NULL`, `list_transform` preserves `NULL` elements; `list_filter` drops elements whose predicate evaluates to `NULL`. Never write subqueries inside lambdas; subqueries raise a binder error. If legacy syntax is required to unblock queries, run `SET lambda_syntax = 'enable_single_arrow';` (removed in 2.1). To filter projection columns by name, write `COLUMNS(lambda c: ...)`; supply an optional second argument `lambda c, i:` for the 1-based column index. ## Division and decimals | Expression | Result | | --- | --- | | `5 / 2` | `2.5`, `DOUBLE` | | `5 // 2` | `2`, truncates toward zero | | `-5 // 2` | `-2`, not floor | | `fdiv(-5, 2)` | `-3.0`