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"],