Skip to content
Snippets Groups Projects
Unverified Commit 3e9f4ac5 authored by Kamil Mielnik's avatar Kamil Mielnik Committed by GitHub
Browse files

Fix - `diagnose-expression` throws when `Offset` is nested (#42497)

* Fix offset not working in case

* Make offset function return any

* Add a repro for #42377

* Fix order of adjustments

* Revert unrelated changes

* Remove commented code

* Revert unrelated changes
parent a522cd88
No related branches found
No related tags found
No related merge requests found
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import type { StructuredQuestionDetails } from "e2e/support/helpers";
import {
createQuestion,
enterCustomColumnDetails,
getNotebookStep,
openNotebook,
popover,
restore,
} from "e2e/support/helpers";
const { ORDERS_ID } = SAMPLE_DATABASE;
describe("scenarios > question > offset", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
});
it("should allow using OFFSET as a CASE argument (metabase#42377)", () => {
const formula = "Sum(case([Total] > 0, Offset([Total], -1)))";
const name = "Aggregation";
const questionDetails: StructuredQuestionDetails = {
query: {
"source-table": ORDERS_ID,
limit: 5,
},
};
createQuestion(questionDetails, { visitQuestion: true });
openNotebook();
cy.icon("sum").click();
getNotebookStep("summarize")
.findByText("Pick the metric you want to see")
.click();
popover().contains("Custom Expression").click();
enterCustomColumnDetails({ formula, name });
cy.on("uncaught:exception", error => {
expect(error.message.includes("Error normalizing")).not.to.be.true;
});
});
});
......@@ -228,8 +228,8 @@ function prattCompiler({
passes: [
adjustOptions,
useShorthands,
adjustCase,
adjustOffset,
adjustCase,
expression =>
resolve({
expression,
......
......@@ -372,6 +372,6 @@ export const parse = pipe(
recursiveParse,
adjustOptions,
useShorthands,
adjustCase,
adjustOffset,
adjustCase,
);
......@@ -25,7 +25,7 @@ interface Opts {
export function compile(source: string, type: Type, opts: Opts = {}) {
const { throwOnError } = opts;
const passes = [adjustOptions, useShorthands, adjustCase, adjustOffset];
const passes = [adjustOptions, useShorthands, adjustOffset, adjustCase];
return newCompile(
parse(lexify(source), {
throwOnError,
......
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