From bd0d5af657fa4bed0c0e23b712bf923b29a18083 Mon Sep 17 00:00:00 2001 From: Nick Woolmer <29717167+nwoolmer@users.noreply.github.com> Date: Thu, 22 Oct 2026 18:17:36 +0100 Subject: [PATCH] feat: add percentile_cont, percentile_disc and quantile aliases QuestDB added exact percentile functions in questdb/questdb#6680: percentile_cont and percentile_disc, plus their quantile_cont and quantile_disc aliases. They work as aggregates and as whole-partition window functions. Add them to the aggregate function list so the web console highlights and autocompletes them. Co-Authored-By: Claude Opus 5.5 (1M context) --- src/grammar/functions.ts | 4 ++++ tests/autocomplete.test.ts | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/grammar/functions.ts b/src/grammar/functions.ts index 77da0f4..f40aa61 100644 --- a/src/grammar/functions.ts +++ b/src/grammar/functions.ts @@ -261,6 +261,10 @@ export const aggregateFunctions: string[] = [ "min", "mode", "nsum", + "percentile_cont", + "percentile_disc", + "quantile_cont", + "quantile_disc", "regr_intercept", "regr_r2", "regr_slope", diff --git a/tests/autocomplete.test.ts b/tests/autocomplete.test.ts index 86d4117..cbf9439 100644 --- a/tests/autocomplete.test.ts +++ b/tests/autocomplete.test.ts @@ -4404,6 +4404,24 @@ describe("Position-typed suggestions — by statement type", () => { assertAtPosition("SELECT s", { hasFunction: ["sparkline"] }) }) + it("SELECT p| — percentile_cont/percentile_disc (aggregate) suggested in expression context", () => { + assertAtPosition("SELECT p", { + hasFunction: ["percentile_cont", "percentile_disc"], + }) + }) + + it("SELECT q| — quantile_cont/quantile_disc (aggregate) suggested in expression context", () => { + assertAtPosition("SELECT q", { + hasFunction: ["quantile_cont", "quantile_disc"], + }) + }) + + it("SELECT * FROM trades WHERE col = p| — percentile_* NOT suggested (aggregate)", () => { + assertAtPosition("SELECT * FROM trades WHERE price = p", { + noFunction: ["percentile_cont", "percentile_disc"], + }) + }) + it("SELECT * FROM trades WHERE col = s| — sparkline NOT suggested (aggregate)", () => { assertAtPosition("SELECT * FROM trades WHERE price = s", { noFunction: ["sparkline"],