motherduck-duckdb-sql

Provides DuckDB SQL syntax and function reference for MotherDuck compatibility checks.

Updated Oct 15, 2019
One-click install
npx skills add https://github.com/kkkaoru/dotfiles --skill motherduck-duckdb-sql-kkkaoru
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: motherduck-duckdb-sql
Source: https://github.com/kkkaoru/dotfiles/tree/main/.agents/skills-stroage/motherduck-duckdb-sql
Command: npx skills add https://github.com/kkkaoru/dotfiles --skill motherduck-duckdb-sql-kkkaoru

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing SQL for MotherDuck requires knowing exact DuckDB syntax and which features MotherDuck actually supports, since PostgreSQL-oriented SQL often fails and upstream DuckDB releases can outpace MotherDuck's supported versions. ## Core Features & Use Cases - Syntax Reference: Covers DuckDB data types, string, numeric, date/time, aggregate, window, JSON, list, spatial, and H3 functions with concrete examples. - MotherDuck Compatibility Checks: Distinguishes MotherDuck-only commands (shares, secrets, snapshots, SHUTDOWN) from upstream DuckDB features that may not yet be supported, such as VARIANT, native GEOMETRY, and MERGE INTO. - SQL Porting Guidance: Translates PostgreSQL-style SQL into DuckDB-native constructs like GROUP BY ALL, QUALIFY, UNION BY NAME, and arg_max. - Use Case: When a query ported from PostgreSQL fails on MotherDuck, use this Skill to rewrite date arithmetic, identifier quoting, and type casts into valid DuckDB SQL. ## Quick Start Ask the AI to check whether a specific SQL statement will run on MotherDuck and rewrite it in DuckDB syntax if needed.

Frequently Asked Questions about motherduck-duckdb-sql

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write DuckDB SQL that works on MotherDuck?

Write DuckDB-native SQL rather than PostgreSQL syntax, even when connecting through the Postgres endpoint. Use fully qualified database.schema.table names and prefer DuckDB constructs like GROUP BY ALL, QUALIFY, and arg_max.

Does MotherDuck support the latest DuckDB features?

MotherDuck can lag upstream DuckDB releases, so newer features like VARIANT, native GEOMETRY, MERGE INTO, and date_trunc return-type changes must be verified against MotherDuck's version-lifecycle docs before production use.

Why does my PostgreSQL query fail on MotherDuck?

PostgreSQL SQL often fails because DuckDB differs in function names, date arithmetic, identifier quoting, and type casts. Translate these elements explicitly into DuckDB syntax instead of assuming compatibility.

What DuckDB functions are available for JSON and lists?

DuckDB provides json_extract, json_extract_string, and ->> operators for JSON, plus list_transform, list_filter, list_reduce, and UNNEST for lists. The json extension is pre-installed on MotherDuck.

Can I use DuckDB spatial and H3 functions on MotherDuck?

Yes, the spatial and h3 extensions are pre-installed on MotherDuck, providing ST_Point, ST_Distance, ST_Intersects, h3_latlng_to_cell, and h3_grid_disk among other functions.