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

Cover `Offset()` in custom expressions with e2e tests (#42756)

* [MBQL lib] Reject broken uses of `offset` in expressions, filters (#42662)

- Using `offset` in custom expressions is supported only when there is
  an order-by defined on that stage.
- Using `offset` in custom filters is not supported at all, currently.

* Support `Offset()` in custom columns [frontend] (#42326)

* Only nest expressions referenced in breakouts or aggregations

* Support Offset() as expression with no breakouts

* Test fixes :wrench:

* Oracle test update

* Improved Oracle test

* Test update :wrench:



* Fix busted test

* Add naive support for Offset() in expressions

* Introduce MBQLClauseFunctionReturnType

* Add "window" to MBQLClauseFunctionReturnType and use it for the offset function

* Handle offset type inference

* Remove unused export

* Use "expression" instead of "window" return type
- Rename identifiers in isCompatible
- Make isCompatible accept a clause object instead of just the type
- Handle offset as a special case in isCompatible

* Use any type

* Rename expectedArgumentType to expectedType

* Format code

* Sort types

* Do not suggest offset function in filters

* Fix offset not working in case

* Revert "Do not suggest offset function in filters"

This reverts commit e63790b78010a6ebdb9f7452afadc8d00e2b3e99.

* Fix order of adjustments

---------

Co-authored-by: default avatarCam Saul <github@camsaul.com>
Co-authored-by: default avatarCam Saul <1455846+camsaul@users.noreply.github.com>

* Disable offsets in filters expressions

* Group existing aggregations-specific tests

* Remove repro for a closed issue

* Use findByText instead of contains

* Add a test for filter expressions

* Add a test for aggregation expressions suggestions

* Disable offsets in filters expressions (#42755)

* Add a test for custom column suggestions

* Add "typing" to enterCustomColumnDetails

* Use enterCustomColumnDetails, improve assertions

* Add more assertions

* Optimize queries

* Add typing for offset expressions

* Add a repro for metabase#42764

* Add a TODO

* Add a TODO

* Add a TODO

* Use NumericLiteral

* Post-merge fixes

* Update test

* Add tests for other custom expressions

* Test drills

* Format code

* Update test name

* Add an assertion

* Add assertions for the preview

* Unskip fixed issue

---------

Co-authored-by: default avatarBraden Shepherdson <braden@metabase.com>
Co-authored-by: default avatarCam Saul <github@camsaul.com>
Co-authored-by: default avatarCam Saul <1455846+camsaul@users.noreply.github.com>
parent 09c557cd
Branches
Tags
No related merge requests found
......@@ -2,7 +2,12 @@ export function expressionEditorWidget() {
return cy.findByTestId("expression-editor");
}
export function enterCustomColumnDetails({ formula, name } = {}) {
/**
* @param {Object} option
* @param {string} option.formula
* @param {string=} option.name
*/
export function enterCustomColumnDetails({ formula, name }) {
cy.get(".ace_text-input")
.first()
.as("formula")
......
This diff is collapsed.
......@@ -124,6 +124,12 @@ type OrderableValue = NumericLiteral | DatetimeLiteral;
type RelativeDatetimePeriod = "current" | "last" | "next" | number;
type OffsetOptions = {
"lib/uuid": string;
name: string;
"display-name": string;
};
// "card__4" like syntax meaning a query is using card 4 as a data source
type NestedQueryTableId = string;
......@@ -155,12 +161,7 @@ type StdDevAgg = ["stddev", ConcreteFieldReference];
type SumAgg = ["sum", ConcreteFieldReference];
type MinAgg = ["min", ConcreteFieldReference];
type MaxAgg = ["max", ConcreteFieldReference];
type OffsetAgg = [
"offset",
{ "lib/uuid": string; name: string; "display-name": string },
Aggregation,
number,
];
type OffsetAgg = ["offset", OffsetOptions, Aggregation, NumericLiteral];
type CommonAggregation =
| CountAgg
......@@ -364,6 +365,7 @@ export type Expression =
| boolean
| [ExpressionOperator, ExpressionOperand]
| [ExpressionOperator, ExpressionOperand, ExpressionOperand]
| ["offset", OffsetOptions, ExpressionOperand, NumericLiteral]
| [
ExpressionOperator,
ExpressionOperand,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment