DuckDB analytical expression helpers for Ecto queries.
These macros wrap DuckDB-specific SQL functions in Ecto.Query.API.fragment/1
so analytical queries can stay in Ecto's query DSL instead of scattering raw
fragment strings across application code.
import Ecto.Query
import QuackDB.Ecto.Analytics
from(event in "events",
group_by: event.category,
select: %{
category: event.category,
median_score: median(event.score),
p95_score: quantile_cont(event.score, 0.95),
scores: duckdb_list(event.score)
}
)Helpers only build expressions. DuckDB clauses that are not representable in
Ecto's AST, such as PIVOT, UNPIVOT, QUALIFY, GROUPING SETS, and
USING SAMPLE, should still be sent as raw SQL.