Skip to content
Snippets Groups Projects
Unverified Commit b4ee5bb0 authored by Ariya Hidayat's avatar Ariya Hidayat Committed by GitHub
Browse files

Fix custom expression being to aggresive in an aggregation (#21834)

parent 4af6b217
No related branches found
No related tags found
No related merge requests found
......@@ -48,6 +48,9 @@ const isCompatible = (a, b) => {
if (a === "aggregation" && b === "number") {
return true;
}
if (a === "number" && b === "aggregation") {
return true;
}
return false;
};
......
......@@ -201,6 +201,20 @@ describe("metabase/lib/expressions/recursive-parser", () => {
expect(aggregation("1+CumulativeCount")).toEqual(["+", 1, ["cum-count"]]);
});
it("should handle aggregation with another function", () => {
const type = "aggregation";
const aggregation = expr => resolve(parse(expr), type, mockResolve);
const A = ["dimension", "A"];
const B = ["dimension", "B"];
expect(aggregation("floor(Sum(A))")).toEqual(["floor", ["sum", A]]);
expect(aggregation("round(Distinct(B)/2)")).toEqual([
"round",
["/", ["distinct", B], 2],
]);
});
it("should prioritize existing metrics over functions", () => {
const mockResolve = (kind, name) => {
if (name === "Count" || "ABC".indexOf(name) >= 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment