duckdb
Process JSON with DuckDB — schema inference, SQL queries, complex joins, and streaming. Use when Nushell pipelines aren't enough for JSON analytics.
What this skill does
# DuckDB JSON Processing
DuckDB excels at JSON analytics: schema inference, SQL queries, complex joins, and streaming. Use when Nushell pipeline commands aren't enough.
## Loading JSON
### read_json — Auto-Detect Schema
Reads JSON files or URLs, auto-detects structure into typed columns. Arrays and objects become [composite types](https://duckdb.org/docs/sql/data_types/overview.html#nested--composite-types).
```sql
-- Load from URL or file
select * from read_json('https://api.example.com/data');
select * from read_json('data.json');
-- In-memory (no .db file)
duckdb :memory:
```
Date-like columns auto-cast to `timestamp`. Use explicit schema for control:
```sql
-- Explicit column types
select * from read_json('films.json', columns = {
title: varchar, release_date: date, created: timestamp
});
-- Cast specific columns
select title, created::datetime from read_json('films.json');
```
### Unstructured JSON Mode
Returns raw JSON blobs instead of auto-detected columns:
```sql
-- Single column of JSON blobs
select json_data from read_json('data.json',
format = 'unstructured', columns = {json_data: 'json[]'});
-- Unfold into rows
select unnest(json_data) as raw from read_json('data.json',
format = 'unstructured', columns = {json_data: 'json[]'});
```
## Inspecting JSON Structure
### json_structure — Schema Detection
Returns the inferred schema of a JSON blob:
```sql
select json_structure(raw_data) from my_table limit 1;
-- {"title":"VARCHAR","episode_id":"UBIGINT",...}
```
Use with `from_json` for type conversion:
```sql
set variable json_schema = (select json_structure(raw_data) from my_table limit 1);
select from_json(raw_data, getvariable('json_schema')) as typed from my_table;
```
### json_keys — Top-Level Keys
```sql
select unnest(json_keys(raw_data)) as keys from my_table limit 1;
```
### unnest — Struct to Columns
Converts a struct into actual columns:
```sql
select unnest(from_json(raw_data, getvariable('json_schema'))) as row from my_table;
```
## Extracting Values
### json_extract (`->`) and json_extract_string (`->>`)
```sql
select
raw_data->>'title' as title,
(raw_data->>'episode_id')::uint64 as episode_id,
(raw_data->'characters')::varchar[] as characters
from my_table;
-- Equivalent function form
select json_extract_string(raw_data, 'title') as title from my_table;
```
### Unfolding Arrays into Rows
```sql
select
json_extract_string(raw_data, 'title') as title,
unnest(cast(json_extract(raw_data, 'characters') as varchar[])) as character_id
from my_table;
```
**Warning**: Using `unnest` on two different columns zips them by position. Normalize one table at a time.
## Creating JSON
### Struct Literal Syntax
Compose nested structures with `{ key: value }` syntax:
```sql
select {
type: 'character',
name: character.name,
homeworld: { type: 'planet', name: planet.name, climate: planet.climate },
species: species.name
} as character
from character
join planet on planet.url = character.homeworld
left join species on species.url = character.species[1];
```
### array_agg — Fold Values into Arrays
Inverse of `unnest` — groups rows back into arrays:
```sql
select
{ type: 'film', title: title, characters: array_agg(character_blob) } as film
from film_character
join character_blob on character_blob.url = film_character.character
group by film_character.url, film_character.title;
```
### to_json — Cast to JSON String
```sql
select to_json(film_struct) as film_json from film_blob;
-- json() and json_string() are equivalent
```
## Writing JSON
### copy — Export JSON
```sql
-- Line-delimited JSON (default)
copy film to 'output.ndjson';
-- JSON array
copy film to 'output.json' (format json, array true);
```
## Streaming JSON
Process JSON without intermediate files:
```sh
# stdin → transform → stdout
echo '[{"a":1,"b":[2,3]}]' | duckdb -json -c \
"select a, unnest(b) as b from read_json('/dev/stdin')"
# Database → stdout
duckdb -c "copy (select title, unnest(characters) from film) to '/dev/stdout' (format json, array true)" db.db
```
## Key Functions Reference
| Function | Purpose |
| ----------------------------- | -------------------------------------- |
| `read_json()` | Load JSON file or URL with auto-schema |
| `json_structure()` | Infer schema from JSON blob |
| `json_keys()` | List top-level keys |
| `json_extract` (`->`) | Extract value as JSON |
| `json_extract_string` (`->>`) | Extract value as string |
| `from_json()` | Transform JSON to native type |
| `to_json()` | Cast native type to JSON |
| `unnest()` | Unfold array into rows |
| `array_agg()` | Fold rows into array |
## Resources
- [DuckDB JSON Documentation](https://duckdb.org/docs/data/json/overview)
- [MotherDuck: Analyze JSON with SQL](https://motherduck.com/blog/analyze-json-data-using-sql/)
- [DuckDB Blog: Shredding Nested JSON](https://duckdb.org/2023/03/03/json.html)
- [Wrangling JSON with DuckDB](https://bnm3k.github.io/blog/wrangling-json-with-duckdb/)
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.