{"slug": "what-do-duckdb-and-slayer-have-in-common", "title": "What do DuckDB and SLayer have in common?", "summary": "MotleyAI published two example notebooks showing how its SLayer semantic layer can be combined with DuckDB to query a remote dataset in a handful of lines, with one notebook driven from the CLI and one from Python. Each notebook defines a view over a remote file in DuckDB, connects SLayer to that view, and runs a query that computes a dimension from an aggregate and applies a rank(precipitation:sum) transform in a measure at query time. MotleyAI argues the resulting SLayer query is easier to read and more reliably generated by an agent than the equivalent SQL.", "body_md": "SLayer and DuckDB are both lightweight, and can be run both embedded and via a CLI (as well as MCP and other ways ;) ) — no server to run if you don’t want to, no warehouse to provision.\n\nDuckDB can read a file straight off a URL over `httpfs`; SLayer can auto-ingest a schema during datasource setup, and then turns its simple yet powerful query syntax into the correct SQL.\n\nPut them together and a semantic layer over a remote dataset is a handful of lines.\n\nTo show just how simple and powerful that pattern is, I’ve put together example notebooks, one for CLI, one for Python.\n\nEach notebook shows, from scratch, how to define a view over a remote file in DuckDB, then to connect SLayer to that view, and to execute a deceptively simple query, containing:\n\n- a **dimension computed from an aggregate** — group each month*warm* or*cool* by its average high temperature, a`CASE WHEN temp_max:avg(partition_by=date) …` band used as a grouping dimension; and\n- a **ranking transform in a measure** —`rank(precipitation:sum)` to order the months by rainfall, one of SLayer’s query-time[transforms](https://github.com/MotleyAI/slayer/blob/main/docs/concepts/formulas.md) .\n\nBoth of these are defined at query time, showing how SLayer frees you from having to pre-configure every little thing you want to query.\n\nWhy would you want to use SLayer at all, instead of direct SQL? The final cell of each notebook shows the SQL corresponding to that “simple” query json. You be the judge which one is easier to read, and which one an agent is more likely to generate correctly, time after time.\n\n## Two ways in\n\n- **[Notebook — CLI](https://github.com/MotleyAI/slayer/blob/main/docs/examples/15_duckdb/duckdb_cli_nb.ipynb)** — the same demo driven entirely from the command line: one simple command each to\n  - install the DuckDB CLI,\n  - expose the remote CSV as a view,\n  - connect SLayer, automatically ingesting the schema into a model\n  - query it with `slayer query` .\n- **[Notebook — Python](https://github.com/MotleyAI/slayer/blob/main/docs/examples/15_duckdb/duckdb_python_nb.ipynb)** — the same logic calling SLayer and DuckDB directly in Python code.", "url": "https://wpnews.pro/news/what-do-duckdb-and-slayer-have-in-common", "canonical_source": "https://motley.ai/blog-posts/what-do-duckdb-and-slayer-have-in-common", "published_at": "2026-09-16 00:00:00+00:00", "updated_at": "2026-09-16 10:42:32.413680+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "ai-products"], "entities": ["MotleyAI", "SLayer", "DuckDB"], "alternates": {"html": "https://wpnews.pro/news/what-do-duckdb-and-slayer-have-in-common", "markdown": "https://wpnews.pro/news/what-do-duckdb-and-slayer-have-in-common.md", "text": "https://wpnews.pro/news/what-do-duckdb-and-slayer-have-in-common.txt", "jsonld": "https://wpnews.pro/news/what-do-duckdb-and-slayer-have-in-common.jsonld"}}