Duckdb sql

From SignalPilot-Labs/SignalPilot · View interactive version

Duckdb sql is an AI agent skill from the GitHub repository SignalPilot-Labs/SignalPilot. Load when hitting DuckDB syntax errors or writing DuckDB-specific SQL. Covers gotchas that differ from PostgreSQL/MySQL.

How to use this skill

Skill file

DuckDB SQL — Key Differences from PostgreSQL/MySQL

Gotchas

cast the FINAL output to match: CAST(ROUND(AVG(col), 2) AS DECIMAL(6,2)).

Do NOT cast the input — cast the result after rounding.

Date Parsing

QUALIFY Clause

Filter window function results without a subquery:

SELECT *, ROW_NUMBER() OVER (PARTITION BY group ORDER BY col DESC) AS rn
FROM table
QUALIFY rn <= 10

Date Spines

SELECT UNNEST(GENERATE_SERIES(min_date::DATE, max_date::DATE, INTERVAL '1' DAY)) AS date_day

Always use the primary fact table's max date as endpoint — call get_date_boundaries first.

Type Casting

CAST(x AS INTEGER), CAST(x AS DOUBLE), CAST(x AS VARCHAR), CAST(x AS DATE)

TRY_CAST returns NULL on failure.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.