Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Duckdb Analytics?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/sickn33-duckdb-analytics)
---
name: duckdb-analytics
description: "Query, aggregate, and transform Parquet, Arrow, and Polars datasets with DuckDB. Verify Hive partition pruning, tune memory spill limits, and isolate worker cursors."
category: data
risk: safe
source: self
source_type: self
date_added: "2026-11-30"
author: ShianMike
tags: [duckdb, parquet, arrow, polars, analytics, sql]
---
# DuckDB Analytics
## When to Use
- Run analytical SQL over local or partitioned Parquet, CSV, or JSON files without provisioning a database server.
- Combine DuckDB SQL queries with Polars or PyArrow tables via zero-copy Arrow exchange.
- Debug slow scans, out-of-memory errors, or thread-concurrency issues in embedded DuckDB pipelines.
## Prerequisites
Identify the DuckDB version (`duckdb.__version__` or `SELECT version()`), host language binding, available RAM and scratch disk, and input file layout (single files, glob patterns, or Hive-partitioned directories). Inspect how connections, cursors, and registered DataFrames are shared across threads, and confirm read-only vs write access before attaching persistent `.duckdb` files or writing Parquet output.
## Verify partition and filter pushdown
1. Pass explicit options such as `hive_partitioning = true` and `union_by_name = true` (only when schema drift across files is expected) to `read_parquet`. Bind query paths and filter values with positional (`$1`) or named (`$region`) parameters instead of interpolating untrusted strings into SQL.
2. Run `EXPLAIN (FORMAT JSON)` before executing expensive aggregations over large directory globs (avoid matching exact boxed ASCII line wrapping, which varies across DuckDB releases). Inspect the `READ_PARQUET` operator's `extra_info` to confirm `File Filters` and `Scanning Files` show partition pruning and that row-level predicates appear as `Filters` inside `READ_PARQUET` rather than only after a full scan.
3. Project only the columns required by the query. Avoid `SELECT *` on wide Parquet datasets, since DuckDB's columnar reader skips unreferenced column chunks.
## Exchange DataFrames cleanly and isolate cursors
- In Python DuckDB 2.x, use the Relation API (`con.sql(query, params=[...]).pl()` or `.to_arrow_table()`) for zero-copy Polars/Arrow output rather than calling `.to_arrow_table()` on a DB-API `con.execute(...)` cursor, which makes an extra copy.
- Do not share a single `DuckDBPyConnection` concurrently across threads. Create an isolated worker cursor via `con.cursor()` per thread.
- Remember that `cursor.register("name", df)` binds a Python DataFrame only on that cursor. Register DataFrames on the worker cursor executing the query, or materialize shared data into a DuckDB table when multiple cursors need it.
## Bound memory, spill disk, and file writes
- Set explicit `SET memory_limit = '...'`, `SET temp_directory = '...'`, and `SET threads = N` in container or CI environments so DuckDB spills predictably instead of triggering the OS OOM killer.
- Open persistent database files with `read_only = True` when only querying so multiple reader processes can attach safely.
- When exporting partitioned datasets with `COPY (...) TO '...' (FORMAT PARQUET, PARTITION_BY (...))`, write into a staging directory or check `OVERWRITE_OR_IGNORE` / `ALLOW_OVERWRITE` explicitly rather than mutating live output paths in place.
## Example
> Query a Hive-partitioned Parquet order dataset, prove DuckDB prunes unneeded partition files, and join Polars DataFrames across isolated cursors without extra Arrow copies.
Run the [worked Parquet and Polars test](references/parquet-and-polars.md) to verify `EXPLAIN` file pruning (`Scanning Files: 2/4`), zero-warning `sql(..., params=...).pl()` output, and cursor-local registration isolation.
## Limitations
- DuckDB is designed for OLAP queries and batch analytics, not high-concurrency OLTP row updates across multiple writer processes.
- Remote object-store scans (`httpfs` / `s3://` / `gs://`) require extension loading and explicit credentials; test network and permission behavior in the target environment.
- DuckDB 1.x and 2.x differ in some Python cursor/relation convenience methods (such as `.pl()` on relations vs DB-API connections); check the installed version before writing bindings.
## Safety and Side Effects
Inspect file globs and output paths before running `COPY ... TO`. Use `read_only = True` when inspecting existing `.duckdb` files, avoid loading unreviewed third-party community extensions, and never interpolate untrusted user input into SQL strings or file paths. Keep credentials out of query strings and logs.
## Related Skills and Documentation
- For expression-based DataFrame pipelines in Python and Rust, see [Polars](https://github.com/sickn33/agentic-awesome-skills/blob/main/skills/polars/SKILL.md).
- For general query-plan analysis and indexing fundamentals, see [SQL Optimization Patterns](https://github.com/sickn33/agentic-awesome-skills/blob/main/skills/sql-optimization-patterns/SKILL.md).
- For labeled multi-dimensional scientific arrays, see [Xarray Coordinate Alignment](https://github.com/sickn33/agentic-awesome-skills/blob/main/skills/xarray-coordinate-alignment/SKILL.md).
- See DuckDB's official documentation on [Parquet files & Hive partitioning](https://duckdb.org/docs/stable/data/parquet/overview), [Python Relational API](https://duckdb.org/docs/stable/clients/python/relational_api), and [Configuration & memory limits](https://duckdb.org/docs/stable/configuration/overview).