skills/duckdb/SKILL.md
DuckDB patterns for JSON/JSONL analysis, array unnesting, and common gotchas. Use when querying JSON files, nested data, or encountering "UNNEST not supported here" errors.
npx skillsauth add jcsaaddupuy/badrobots duckdbInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
-- Load multiple JSONL files with schema variations
SELECT * FROM read_ndjson('path/**/*.jsonl',
union_by_name=true, -- Handle varying schemas across files
filename=true -- Include source file path
);
-- Use (unnest(col)).field syntax for struct field access
SELECT
id,
(unnest(message.content)).name as tool_name,
(unnest(message.content)).type as content_type,
(unnest(message.content)).arguments::VARCHAR as args
FROM sessions;
-- WRONG: UNNEST not supported in WHERE
SELECT * FROM t WHERE (unnest(col)).type = 'x'; -- ERROR!
-- CORRECT: Use temp table approach
CREATE TEMP TABLE extracted AS
SELECT id, (unnest(col)).field as f FROM source;
SELECT * FROM extracted WHERE f = 'x';
After unnesting, aggregate back to original entity:
-- Get dominant value per group (MODE)
SELECT id,
(SELECT value FROM unnested t2
WHERE t2.id = t1.id
GROUP BY value
ORDER BY COUNT(*) DESC
LIMIT 1) as dominant
FROM (SELECT DISTINCT id FROM source) t1;
Cast JSON arguments to VARCHAR for ILIKE:
-- JSON fields need casting for string matching
SELECT * FROM tools
WHERE args::VARCHAR ILIKE '%pattern%';
-- Filter out NULL tool names from unnested arrays
WHERE tool_name IS NOT NULL AND content_type = 'toolCall'
-- Drop temp tables when done with large datasets
DROP TABLE IF EXISTS temp_table;
-- Or use CREATE TEMP TABLE (auto-drops on session end)
CREATE TEMP TABLE intermediate AS
SELECT * FROM source WHERE condition;
| Error | Cause | Fix |
|-------|-------|-----|
| "UNNEST not supported here" | UNNEST in WHERE clause | Use temp table |
| "Table does not have column named 'x'" | Wrong struct access syntax | Use (unnest(col)).field |
| "Set operations require same columns" | UNION with mismatched columns | Align SELECT lists |
| JSON text not matching | Uncast JSON field | Cast to VARCHAR: field::VARCHAR ILIKE |
development
Mealie recipe manager API: recipes, shopping lists, meal plans. Requires MEALIE_BASE_URL and MEALIE_API_KEY.
business
TimeWarrior time tracking: start/stop intervals, query durations by tag or issue, compute totals for issue tracker time reporting
development
Bookmark manager for saving, searching, and annotating web content. Use when: (1) saving a webpage for later reference, (2) searching previously saved bookmarks, (3) adding highlights/annotations to saved content, (4) user asks to 'bookmark this' or 'save this article'. Requires READECK_BASE_URL and READECK_API_KEY environment variables.
data-ai
YAML parsing and manipulation with yq