The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Show non-aggregation functions in aggregations (#62989)
Romeo Van Snick6ce3e4b2505e
diff --git a/e2e/test/scenarios/custom-column/custom-column-reproductions.cy.spec.js b/e2e/test/scenarios/custom-column/custom-column-reproductions.cy.spec.jsindex 910443d0f17..b8304b1f312 100644--- a/e2e/test/scenarios/custom-column/custom-column-reproductions.cy.spec.js+++ b/e2e/test/scenarios/custom-column/custom-column-reproductions.cy.spec.js@@ -2460,3 +2460,38 @@ describe("issue 61010", () => {.should("be.visible");});});++describe("issue 62987", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsNormalUser();+ H.createQuestion(+ {+ query: { "source-table": ORDERS_ID },+ },+ { visitQuestion: true },+ );++ H.openNotebook();+ H.summarize({ mode: "notebook" });+ H.popover().findByText("Custom Expression").click();+ });++ it("should be possible to complete non-aggregation functions in custom aggregation (metabase#62987)", () => {+ H.CustomExpressionEditor.type("Coun");+ H.CustomExpressionEditor.completion("CountIf").should("be.visible").click();++ H.CustomExpressionEditor.type("notEm", { focus: false });+ H.CustomExpressionEditor.completion("notEmpty")+ .should("be.visible")+ .click();++ H.CustomExpressionEditor.value().should("eq", "CountIf(notEmpty(column))");++ H.expressionEditorWidget().button("Function browser").click();+ H.CustomExpressionEditor.functionBrowser().within(() => {+ cy.findByText("CountIf").should("be.visible");+ cy.findByText("notEmpty").should("be.visible");+ });+ });+});diff --git a/frontend/src/metabase/querying/expressions/config.ts b/frontend/src/metabase/querying/expressions/config.tsindex 34b1ef20bb9..fdc6ad73d85 100644--- a/frontend/src/metabase/querying/expressions/config.ts+++ b/frontend/src/metabase/querying/expressions/config.ts@@ -1855,11 +1855,6 @@ export const EXPRESSION_OPERATORS = {...COMPARISON_OPERATORS,} as const;-export const AGGREGATION_FUNCTIONS = {- ...AGGREGATION,- ...WINDOW,-} as const;-export const EXPRESSION_FUNCTIONS = {...CONVERSION,...STRING,@@ -1868,6 +1863,12 @@ export const EXPRESSION_FUNCTIONS = {...LOGICAL,} as const;+export const AGGREGATION_FUNCTIONS = {+ ...EXPRESSION_FUNCTIONS,+ ...AGGREGATION,+ ...WINDOW,+} as const;+export const MBQL_CLAUSES = {...AGGREGATION_FUNCTIONS,...EXPRESSION_FUNCTIONS,diff --git a/frontend/src/metabase/querying/expressions/fuzz.compiler.unit.spec.ts b/frontend/src/metabase/querying/expressions/fuzz.compiler.unit.spec.tsindex 321e62ef0c1..2652fcc3949 100644--- a/frontend/src/metabase/querying/expressions/fuzz.compiler.unit.spec.ts+++ b/frontend/src/metabase/querying/expressions/fuzz.compiler.unit.spec.ts@@ -5,7 +5,11 @@ import { fuzz } from "./test/fuzz";import { generateExpression } from "./test/generator";import { query, stageIndex } from "./test/shared";-const MAX_SEED = 10_000;+/*+ * TODO: This is set to a very low value because the memory+ * blows up in CI. We should figure out why and increase it againt.+ */+const MAX_SEED = 5;function compile(expression: string,diff --git a/frontend/src/metabase/querying/expressions/suggestions/aggregations.unit.spec.ts b/frontend/src/metabase/querying/expressions/suggestions/aggregations.unit.spec.tsindex 5b36d115054..a70729d1b75 100644--- a/frontend/src/metabase/querying/expressions/suggestions/aggregations.unit.spec.ts+++ b/frontend/src/metabase/querying/expressions/suggestions/aggregations.unit.spec.ts@@ -60,48 +60,136 @@ describe("suggestAggregations", () => {to: 4,options: [{- apply: expect.any(Function),+ type: "aggregation",+ label: "Count",displayLabel: "Count",icon: "function",- label: "Count",matches: [[0, 3]],- type: "aggregation",+ apply: expect.any(Function),},{- apply: expect.any(Function),+ type: "aggregation",+ label: "CountIf",displayLabel: "CountIf",icon: "function",- label: "CountIf",matches: [[0, 3]],- type: "aggregation",+ apply: expect.any(Function),},{- apply: expect.any(Function),+ type: "aggregation",+ label: "CumulativeCount",displayLabel: "CumulativeCount",icon: "function",- label: "CumulativeCount",matches: [[0, 1],[3, 3],[10, 13],],+ apply: expect.any(Function),+ },+ {type: "aggregation",+ label: "concat",+ displayLabel: "concat",+ icon: "function",+ matches: [[0, 3]],+ apply: expect.any(Function),},{- displayLabel: "CumulativeSum",+ type: "aggregation",+ label: "contains",+ displayLabel: "contains",+ icon: "function",+ matches: [+ [0, 2],+ [6, 6],+ ],+ apply: expect.any(Function),+ },+ {+ type: "aggregation",+ label: "second",+ displayLabel: "second",+ icon: "function",+ matches: [[2, 4]],+ apply: expect.any(Function),+ },+ {+ type: "aggregation",+ label: "doesNotContain",+ displayLabel: "doesNotContain",+ icon: "function",+ matches: [+ [1, 1],+ [4, 5],+ [7, 9],+ [13, 13],+ ],+ apply: expect.any(Function),+ },+ {+ type: "aggregation",+ label: "coalesce",+ displayLabel: "coalesce",+ icon: "function",+ matches: [+ [0, 1],+ [6, 6],+ ],+ apply: expect.any(Function),+ },+ {+ type: "aggregation",label: "CumulativeSum",+ displayLabel: "CumulativeSum",+ icon: "function",matches: [[0, 1],[3, 3],[11, 11],],+ apply: expect.any(Function),+ },+ {+ type: "aggregation",+ label: "hour",+ displayLabel: "hour",+ icon: "function",+ matches: [[1, 2]],+ apply: expect.any(Function),+ },+ {+ type: "aggregation",+ label: "month",+ displayLabel: "month",icon: "function",+ matches: [[1, 2]],+ apply: expect.any(Function),+ },+ {type: "aggregation",+ label: "monthName",+ displayLabel: "monthName",+ icon: "function",+ matches: [+ [1, 2],+ [5, 5],+ ],+ apply: expect.any(Function),+ },+ {+ type: "aggregation",+ label: "notNull",+ displayLabel: "notNull",+ icon: "function",+ matches: [+ [0, 1],+ [3, 4],+ ],apply: expect.any(Function),},],};-const RESULTS_NO_TEMPLATE = {...RESULTS,options: RESULTS.options.map((option) => ({