Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BE - Add legacyExpressionClause #34830

Closed
Tracked by #30513
ranquild opened this issue Oct 19, 2023 · 0 comments · Fixed by #35936
Closed
Tracked by #30513

BE - Add legacyExpressionClause #34830

ranquild opened this issue Oct 19, 2023 · 0 comments · Fixed by #35936
Assignees
Labels
.Backend .metabase-lib Label for tracking all issues related to the shared CLJC metabase-lib .Team/QueryProcessor :hammer_and_wrench:

Comments

@ranquild
Copy link
Contributor

ranquild commented Oct 19, 2023

Since the parser works with raw mbql, we need to a function get an expression clause from raw mbql.

It's expected to be a simpler wrapper, no data transformation should be needed.

function legacyExpressionClause(
  query: Query,
  stageIndex: number,
  mbql: any
): ExpressionClause
@darksciencebase darksciencebase added .metabase-lib Label for tracking all issues related to the shared CLJC metabase-lib .Backend .Team/QueryProcessor :hammer_and_wrench: labels Nov 7, 2023
metamben added a commit that referenced this issue Nov 17, 2023
kamilmielnik added a commit that referenced this issue Nov 30, 2023
commit 91be09a
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 30 18:39:46 2023 +0700

    Format code

commit 9acc7ba
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 30 18:04:13 2023 +0700

    Use clearer notation

commit 42d5ff1
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 30 17:57:58 2023 +0700

    Deprecate displayName in favor of displayInfo
    - see https://metaboat.slack.com/archives/C0645JP1W81/p1701341786914219?thread_ts=1701335646.088359&cid=C0645JP1W81

commit da11fb9
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 30 17:55:39 2023 +0700

    Use displayInfo instead of displayName
    - see #36203 (comment)

commit fc35005
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 30 15:28:01 2023 +0700

    Add expression name assertion

commit a7ed491
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 30 15:25:02 2023 +0700

    Add expression name assertion

commit 49dfc00
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 30 15:11:44 2023 +0700

    Unskip an e2e test

commit a7a9ec6
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 30 15:10:45 2023 +0700

    Add expression name assertion

commit 9f85ea9
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 30 15:02:54 2023 +0700

    Add expression name assertion

commit 2795c3d
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 30 15:01:32 2023 +0700

    Add expression name assertion

commit 6a0c758
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 30 14:59:24 2023 +0700

    Add expression name assertion

commit e80ac60
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 30 14:57:02 2023 +0700

    Add expression name assertion

commit 33aec8f
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 30 14:54:36 2023 +0700

    Add expression name assertion

commit fd32c5f
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 30 14:52:08 2023 +0700

    Add expression name assertion

commit db71907
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 29 22:18:25 2023 +0700

    Improve assertions in tests

commit b5bfee8
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 29 22:18:07 2023 +0700

    Fix committing expression with done button

commit 45a50d3
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 29 21:46:20 2023 +0700

    Add assertion for expression name

commit 0aec027
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 29 21:32:22 2023 +0700

    Fix legacyQuery creation

commit e719fc2
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 29 20:45:48 2023 +0700

    Add a test case for isExpressionEditorInitiallyOpen (which uses Lib.expressionName)

commit 92aa48f
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 29 18:23:13 2023 +0700

    Remove legacyQuery prop from AggregationPicker

commit f7d14cf
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 29 17:51:02 2023 +0700

    Bring back removed assertion

commit 0a0802a
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 29 17:49:19 2023 +0700

    Bring back using expression in componentWillReceiveProps

commit dcd7781
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 29 17:24:17 2023 +0700

    Update ExpressionWidget validation & tests

commit 594b389
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 29 17:15:19 2023 +0700

    Bring back expression prop for backwards-compatibility

commit c36cebd
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 29 17:09:56 2023 +0700

    Drop a conditional statement

commit 3eb2181
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 29 15:36:44 2023 +0700

    Pass props in ExpressionStep tests in a usual way

commit 7f7152e
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 29 14:54:05 2023 +0700

    Update expressionName signature

commit 8afeac3
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 29 14:53:58 2023 +0700

    Fix isExpressionEditorInitiallyOpen

commit c4866fd
Merge: bacf371 58bd581
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 29 14:25:46 2023 +0700

    Merge branch '36120-omit-aggregation-options-converting-exprs-to-legacy' into 35947-legacy-expression-clause-filters-and-aggregations

commit 58bd581
Author: Tamás Benkő <tamas@metabase.com>
Date:   Wed Nov 29 01:25:02 2023 +0300

    Normalize legacy expressions as MBQL expressions

commit 95ddd4c
Author: Tamás Benkő <tamas@metabase.com>
Date:   Tue Nov 28 00:08:19 2023 +0300

    Omit aggregation options converting expressions to legacy

    Fixes #36120.

commit bacf371
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Tue Nov 28 21:51:04 2023 +0700

    Migrate isExpressionEditorInitiallyOpen to MLv2

commit 505d11f
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Tue Nov 28 18:41:44 2023 +0700

    Get rid of props spread

commit 1e2485c
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Tue Nov 28 14:52:40 2023 +0700

    Remove temporary hack

commit bdad147
Merge: 7baa434 f28b10a
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Tue Nov 28 14:46:58 2023 +0700

    Merge branch '36120-omit-aggregation-options-converting-exprs-to-legacy' into 35947-legacy-expression-clause-filters-and-aggregations

commit f28b10a
Author: Tamás Benkő <tamas@metabase.com>
Date:   Tue Nov 28 00:08:19 2023 +0300

    Omit aggregation options converting expressions to legacy

    Fixes #36120.

commit 7baa434
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Mon Nov 27 21:00:53 2023 +0700

    Fix tests failing due to useSelect usage in AggregationPicker

commit f18cd75
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Mon Nov 27 20:19:14 2023 +0700

    Revert "Use overloading instead of generics"

    This reverts commit 3953f85.

commit ee9d538
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Mon Nov 27 20:17:50 2023 +0700

    Rename operator to clause

commit 2074e8b
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Mon Nov 27 20:07:20 2023 +0700

    Add function body

commit 3953f85
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Mon Nov 27 20:05:31 2023 +0700

    Use overloading instead of generics

commit f36fc18
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Mon Nov 27 19:50:37 2023 +0700

    Update tests with new interface

commit 94bc358
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Mon Nov 27 18:58:28 2023 +0700

    Rename expressionClause to clause

commit 1f13259
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Mon Nov 27 18:58:03 2023 +0700

    Make withExpressionName work with AggregationClause

commit 7658ec9
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Mon Nov 27 18:38:34 2023 +0700

    Allow AggregationClause, drop expression from ExpressionEditorTextfield

commit 079abb5
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Mon Nov 27 16:05:48 2023 +0700

    Use destructuring

commit a9d7b5b
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Fri Nov 24 21:42:55 2023 +0700

    Replace 3rd argument in onChangeExpression with onChangeExpressionClause

commit 0573ab3
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Fri Nov 24 21:20:53 2023 +0700

    Migrate clause name

commit 221e950
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Fri Nov 24 21:12:18 2023 +0700

    Add clause prop to AggregationPicker

commit 39496c1
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Fri Nov 24 20:28:44 2023 +0700

    Add a TODO comment

commit 89041b9
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Fri Nov 24 20:23:38 2023 +0700

    Replace legacyQuery.database() with query + metadata

commit d64c7c4
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Fri Nov 24 20:19:17 2023 +0700

    Use props in a conservative way

commit 5c75c83
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Fri Nov 24 20:15:38 2023 +0700

    Deal with awkward assertions

commit 24a131c
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Fri Nov 24 20:14:11 2023 +0700

    Add stageIndex to setup, use destructuring for onSelect arguments

commit 2f50b3f
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Fri Nov 24 20:05:14 2023 +0700

    Replace toEqual + expect.objectContaining with toMatchObject

commit 30b9b27
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Fri Nov 24 20:00:23 2023 +0700

    Update AggregationPicker tests

commit 71ac3aa
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Fri Nov 24 16:02:26 2023 +0700

    Assert new onChangeExpression argument in test

commit 8646317
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Fri Nov 24 16:01:22 2023 +0700

    Assert new onChangeExpression argument in test

commit 7ae92bd
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Fri Nov 24 15:51:03 2023 +0700

    Use nullish coalescing operator

commit 35dbf4b
Merge: 248009a 3ba6a35
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Fri Nov 24 14:27:48 2023 +0700

    Merge branch 'master' into 35947-legacy-expression-clause-filters-and-aggregations

commit 248009a
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 23 21:07:19 2023 +0700

    Remove onSelectLegacy from AggregationPicker

commit 20e9406
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 23 18:09:21 2023 +0700

    Use onSelect instead of onSelectLegacy in handleExpressionChange

commit cadf4ed
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 23 16:35:33 2023 +0700

    Use new expressionClause in ExpressionWidget

commit 3eb2f3c
Merge: 4eb9eda b159e81
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Thu Nov 23 16:01:23 2023 +0700

    Merge branch 'master' into 35947-legacy-expression-clause-filters-and-aggregations

commit 4eb9eda
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 22 21:21:50 2023 +0700

    Revert changes to ExpressionStep as it's out of scope of this task

commit 3e4fb53
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 22 21:13:10 2023 +0700

    Support MLv2 expressionClause in processSource and ExpressionWidget

commit 3d59ab3
Merge: 9ffa599 d41964f
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 22 18:24:46 2023 +0700

    Merge branch 'master' into 35947-legacy-expression-clause-filters-and-aggregations

commit 9ffa599
Merge: 3233e98 eb24d0d
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 22 15:42:34 2023 +0700

    Merge branch 'refactor/rename-query-to-legacy-query' into 35947-legacy-expression-clause-filters-and-aggregations

commit 3233e98
Merge: 55b4f31 4368da8
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 22 15:32:47 2023 +0700

    Merge branch 'master' into 35947-legacy-expression-clause-filters-and-aggregations

commit eb24d0d
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 22 15:14:15 2023 +0700

    Rename query to legacyQuery in Expressions (part 3)

commit d6eb1dc
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Wed Nov 22 14:53:01 2023 +0700

    Rename query to legacyQuery in Expressions (part 2)

commit 95697f7
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Tue Nov 21 21:55:50 2023 +0700

    Rename query to legacyQuery in Expressions (part 1)

commit 55b4f31
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Tue Nov 21 20:05:40 2023 +0700

    Use Aggregatable type in aggregate function

commit 0994d76
Author: Kamil Mielnik <kamil@kamilmielnik.com>
Date:   Tue Nov 21 20:05:23 2023 +0700

    Include ExpressionClause in Aggregatable type

commit 76054bf
Merge: e93d114 a0004de
Author: Tamás Benkő <tamas@metabase.com>
Date:   Mon Nov 20 23:17:02 2023 +0300

    Merge remote-tracking branch 'origin/master' into 34830-expression-clause-for-legacy-expression

commit e93d114
Author: Tamás Benkő <tamas@metabase.com>
Date:   Mon Nov 20 23:16:03 2023 +0300

    Fix wrapper function name

commit e4df56e
Author: Tamás Benkő <tamas@metabase.com>
Date:   Mon Nov 20 22:40:44 2023 +0300

    Add legacy-expression-for-expression-clause

commit e48ab06
Author: Tamás Benkő <tamas@metabase.com>
Date:   Sat Nov 18 02:37:20 2023 +0300

    Add expression-clause-for-legacy-expression

    Fixes #34830.
kamilmielnik added a commit that referenced this issue Dec 5, 2023
* Add expression-clause-for-legacy-expression

Fixes #34830.

* Add legacy-expression-for-expression-clause

* Fix wrapper function name

* Include ExpressionClause in Aggregatable type

* Use Aggregatable type in aggregate function

* Rename query to legacyQuery in Expressions (part 1)

* Rename query to legacyQuery in Expressions (part 2)

* Rename query to legacyQuery in Expressions (part 3)

* Support MLv2 expressionClause in processSource and ExpressionWidget

* Revert changes to ExpressionStep as it's out of scope of this task

* Use new expressionClause in ExpressionWidget

* Use onSelect instead of onSelectLegacy in handleExpressionChange

* Remove onSelectLegacy from AggregationPicker

* Use nullish coalescing operator

* Assert new onChangeExpression argument in test

* Assert new onChangeExpression argument in test

* Update AggregationPicker tests

* Replace toEqual + expect.objectContaining with toMatchObject

* Add stageIndex to setup, use destructuring for onSelect arguments

* Deal with awkward assertions

* Use props in a conservative way

* Replace legacyQuery.database() with query + metadata

* Add a TODO comment

* Add clause prop to AggregationPicker

* Migrate clause name

* Replace 3rd argument in onChangeExpression with onChangeExpressionClause

* Use destructuring

* Allow AggregationClause, drop expression from ExpressionEditorTextfield

* Make withExpressionName work with AggregationClause

* Rename expressionClause to clause

* Update tests with new interface

* Use overloading instead of generics

* Add function body

* Rename operator to clause

* Revert "Use overloading instead of generics"

This reverts commit 3953f85.

* Fix tests failing due to useSelect usage in AggregationPicker

* Omit aggregation options converting expressions to legacy

Fixes #36120.

* Remove temporary hack

* Get rid of props spread

* Migrate isExpressionEditorInitiallyOpen to MLv2

* Omit aggregation options converting expressions to legacy

Fixes #36120.

* Normalize legacy expressions as MBQL expressions

* Fix isExpressionEditorInitiallyOpen

* Update expressionName signature

* Pass props in ExpressionStep tests in a usual way

* Drop a conditional statement

* Bring back expression prop for backwards-compatibility

* Update ExpressionWidget validation & tests

* Bring back using expression in componentWillReceiveProps

* Bring back removed assertion

* Remove legacyQuery prop from AggregationPicker

* Add a test case for isExpressionEditorInitiallyOpen (which uses Lib.expressionName)

* Fix legacyQuery creation

* Add assertion for expression name

* Fix committing expression with done button

* Improve assertions in tests

* Make with-expression-name set the display-name of the clause

Fixes #36167.

This is needed to be able to set/change the display name of custom aggregation columns too.

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Unskip an e2e test

* Add expression name assertion

* Add expression name assertion

* Use displayInfo instead of displayName
- see #36203 (comment)

* Deprecate displayName in favor of displayInfo
- see https://metaboat.slack.com/archives/C0645JP1W81/p1701341786914219?thread_ts=1701335646.088359&cid=C0645JP1W81

* Use clearer notation

* Format code

* Use displayInfo instead of expressionName in tests

* Add isNamed attribute to ColumnDisplayInfo and ClauseDisplayInfo

* Use displayInfo instead of expressionName in AggregationPicker

* Drop expressionName

* Drop redundant cast

* Simplify isExpressionEditorInitiallyOpen interface

* Use display-info with :named? instead of expression-name

* Improve comment

* Add :named? to the schema of display-info

* Use conditional types for ExpressionWidget prop

* Use getNotebookStep

* Simplify condition

* Simplify assertions

* Use .lastCall

* Remove isNamed attribute from ColumnDisplayInfo

* Use .lastCall

* Fix typing

* Bring back legacyQuery prop to AggregationPicker

* Fix isExpressionEditorInitiallyOpen for new clauses

* Fix unit tests

* Remove wrong assertion

* Fix assertion

* Trigger a change

* Revert "Trigger a change"

This reverts commit 254913d.

* Fix assertion

---------

Co-authored-by: Tamás Benkő <tamas@metabase.com>
kamilmielnik added a commit that referenced this issue Dec 6, 2023
* Add expression-clause-for-legacy-expression

Fixes #34830.

* Add legacy-expression-for-expression-clause

* Fix wrapper function name

* Include ExpressionClause in Aggregatable type

* Use Aggregatable type in aggregate function

* Rename query to legacyQuery in Expressions (part 1)

* Rename query to legacyQuery in Expressions (part 2)

* Rename query to legacyQuery in Expressions (part 3)

* Support MLv2 expressionClause in processSource and ExpressionWidget

* Revert changes to ExpressionStep as it's out of scope of this task

* Use new expressionClause in ExpressionWidget

* Use onSelect instead of onSelectLegacy in handleExpressionChange

* Remove onSelectLegacy from AggregationPicker

* Use nullish coalescing operator

* Assert new onChangeExpression argument in test

* Assert new onChangeExpression argument in test

* Update AggregationPicker tests

* Replace toEqual + expect.objectContaining with toMatchObject

* Add stageIndex to setup, use destructuring for onSelect arguments

* Deal with awkward assertions

* Use props in a conservative way

* Replace legacyQuery.database() with query + metadata

* Add a TODO comment

* Add clause prop to AggregationPicker

* Migrate clause name

* Replace 3rd argument in onChangeExpression with onChangeExpressionClause

* Use destructuring

* Allow AggregationClause, drop expression from ExpressionEditorTextfield

* Make withExpressionName work with AggregationClause

* Rename expressionClause to clause

* Update tests with new interface

* Use overloading instead of generics

* Add function body

* Rename operator to clause

* Revert "Use overloading instead of generics"

This reverts commit 3953f85.

* Fix tests failing due to useSelect usage in AggregationPicker

* Omit aggregation options converting expressions to legacy

Fixes #36120.

* Remove temporary hack

* Get rid of props spread

* Migrate isExpressionEditorInitiallyOpen to MLv2

* Omit aggregation options converting expressions to legacy

Fixes #36120.

* Normalize legacy expressions as MBQL expressions

* Fix isExpressionEditorInitiallyOpen

* Update expressionName signature

* Pass props in ExpressionStep tests in a usual way

* Drop a conditional statement

* Bring back expression prop for backwards-compatibility

* Update ExpressionWidget validation & tests

* Bring back using expression in componentWillReceiveProps

* Bring back removed assertion

* Remove legacyQuery prop from AggregationPicker

* Add a test case for isExpressionEditorInitiallyOpen (which uses Lib.expressionName)

* Fix legacyQuery creation

* Add assertion for expression name

* Fix committing expression with done button

* Improve assertions in tests

* Make with-expression-name set the display-name of the clause

Fixes #36167.

This is needed to be able to set/change the display name of custom aggregation columns too.

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Unskip an e2e test

* Add expression name assertion

* Add expression name assertion

* Use displayInfo instead of displayName
- see #36203 (comment)

* Deprecate displayName in favor of displayInfo
- see https://metaboat.slack.com/archives/C0645JP1W81/p1701341786914219?thread_ts=1701335646.088359&cid=C0645JP1W81

* Use clearer notation

* Format code

* Use displayInfo instead of expressionName in tests

* Add isNamed attribute to ColumnDisplayInfo and ClauseDisplayInfo

* Use displayInfo instead of expressionName in AggregationPicker

* Drop expressionName

* Drop redundant cast

* Simplify isExpressionEditorInitiallyOpen interface

* Use display-info with :named? instead of expression-name

* Improve comment

* Add :named? to the schema of display-info

* Use conditional types for ExpressionWidget prop

* Use getNotebookStep

* Simplify condition

* Simplify assertions

* Use .lastCall

* Remove isNamed attribute from ColumnDisplayInfo

* Use .lastCall

* Fix typing

* Bring back legacyQuery prop to AggregationPicker

* Fix isExpressionEditorInitiallyOpen for new clauses

* Fix unit tests

* Remove wrong assertion

* Fix assertion

* Trigger a change

* Revert "Trigger a change"

This reverts commit 254913d.

* Fix assertion

* Allow FilterClause

* Drop legacyFilter usage from FilterPicker, FilterStep & QuestionFilters

* Update FilterPicker unit tests

* Remove unused function

* Fix types in unit test

* Remove redundant waitFor

* Update ColumnDisplayInfo type

* Revert changes to ColumnDisplayInfo, avoid using semanticType & effectiveType attributes

* Introduce NamedClause and CustomExpressionClause types

* Simplify assertions

* Remove casting from FilterPicker

* Rename NamedClause to CustomNameClause

* Exclude AggregationClause from FilterPicker's interfaces

* Avoid casting using generics
qnkhuat pushed a commit that referenced this issue Dec 12, 2023
* Add expression-clause-for-legacy-expression

Fixes #34830.

* Add legacy-expression-for-expression-clause

* Fix wrapper function name

* Include ExpressionClause in Aggregatable type

* Use Aggregatable type in aggregate function

* Rename query to legacyQuery in Expressions (part 1)

* Rename query to legacyQuery in Expressions (part 2)

* Rename query to legacyQuery in Expressions (part 3)

* Support MLv2 expressionClause in processSource and ExpressionWidget

* Revert changes to ExpressionStep as it's out of scope of this task

* Use new expressionClause in ExpressionWidget

* Use onSelect instead of onSelectLegacy in handleExpressionChange

* Remove onSelectLegacy from AggregationPicker

* Use nullish coalescing operator

* Assert new onChangeExpression argument in test

* Assert new onChangeExpression argument in test

* Update AggregationPicker tests

* Replace toEqual + expect.objectContaining with toMatchObject

* Add stageIndex to setup, use destructuring for onSelect arguments

* Deal with awkward assertions

* Use props in a conservative way

* Replace legacyQuery.database() with query + metadata

* Add a TODO comment

* Add clause prop to AggregationPicker

* Migrate clause name

* Replace 3rd argument in onChangeExpression with onChangeExpressionClause

* Use destructuring

* Allow AggregationClause, drop expression from ExpressionEditorTextfield

* Make withExpressionName work with AggregationClause

* Rename expressionClause to clause

* Update tests with new interface

* Use overloading instead of generics

* Add function body

* Rename operator to clause

* Revert "Use overloading instead of generics"

This reverts commit 3953f85.

* Fix tests failing due to useSelect usage in AggregationPicker

* Omit aggregation options converting expressions to legacy

Fixes #36120.

* Remove temporary hack

* Get rid of props spread

* Migrate isExpressionEditorInitiallyOpen to MLv2

* Omit aggregation options converting expressions to legacy

Fixes #36120.

* Normalize legacy expressions as MBQL expressions

* Fix isExpressionEditorInitiallyOpen

* Update expressionName signature

* Pass props in ExpressionStep tests in a usual way

* Drop a conditional statement

* Bring back expression prop for backwards-compatibility

* Update ExpressionWidget validation & tests

* Bring back using expression in componentWillReceiveProps

* Bring back removed assertion

* Remove legacyQuery prop from AggregationPicker

* Add a test case for isExpressionEditorInitiallyOpen (which uses Lib.expressionName)

* Fix legacyQuery creation

* Add assertion for expression name

* Fix committing expression with done button

* Improve assertions in tests

* Make with-expression-name set the display-name of the clause

Fixes #36167.

This is needed to be able to set/change the display name of custom aggregation columns too.

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Unskip an e2e test

* Add expression name assertion

* Add expression name assertion

* Use displayInfo instead of displayName
- see #36203 (comment)

* Deprecate displayName in favor of displayInfo
- see https://metaboat.slack.com/archives/C0645JP1W81/p1701341786914219?thread_ts=1701335646.088359&cid=C0645JP1W81

* Use clearer notation

* Format code

* Use displayInfo instead of expressionName in tests

* Add isNamed attribute to ColumnDisplayInfo and ClauseDisplayInfo

* Use displayInfo instead of expressionName in AggregationPicker

* Drop expressionName

* Drop redundant cast

* Simplify isExpressionEditorInitiallyOpen interface

* Use display-info with :named? instead of expression-name

* Improve comment

* Add :named? to the schema of display-info

* Use conditional types for ExpressionWidget prop

* Use getNotebookStep

* Simplify condition

* Simplify assertions

* Use .lastCall

* Remove isNamed attribute from ColumnDisplayInfo

* Use .lastCall

* Fix typing

* Bring back legacyQuery prop to AggregationPicker

* Fix isExpressionEditorInitiallyOpen for new clauses

* Fix unit tests

* Remove wrong assertion

* Fix assertion

* Trigger a change

* Revert "Trigger a change"

This reverts commit 254913d.

* Fix assertion

---------

Co-authored-by: Tamás Benkő <tamas@metabase.com>
qnkhuat pushed a commit that referenced this issue Dec 12, 2023
* Add expression-clause-for-legacy-expression

Fixes #34830.

* Add legacy-expression-for-expression-clause

* Fix wrapper function name

* Include ExpressionClause in Aggregatable type

* Use Aggregatable type in aggregate function

* Rename query to legacyQuery in Expressions (part 1)

* Rename query to legacyQuery in Expressions (part 2)

* Rename query to legacyQuery in Expressions (part 3)

* Support MLv2 expressionClause in processSource and ExpressionWidget

* Revert changes to ExpressionStep as it's out of scope of this task

* Use new expressionClause in ExpressionWidget

* Use onSelect instead of onSelectLegacy in handleExpressionChange

* Remove onSelectLegacy from AggregationPicker

* Use nullish coalescing operator

* Assert new onChangeExpression argument in test

* Assert new onChangeExpression argument in test

* Update AggregationPicker tests

* Replace toEqual + expect.objectContaining with toMatchObject

* Add stageIndex to setup, use destructuring for onSelect arguments

* Deal with awkward assertions

* Use props in a conservative way

* Replace legacyQuery.database() with query + metadata

* Add a TODO comment

* Add clause prop to AggregationPicker

* Migrate clause name

* Replace 3rd argument in onChangeExpression with onChangeExpressionClause

* Use destructuring

* Allow AggregationClause, drop expression from ExpressionEditorTextfield

* Make withExpressionName work with AggregationClause

* Rename expressionClause to clause

* Update tests with new interface

* Use overloading instead of generics

* Add function body

* Rename operator to clause

* Revert "Use overloading instead of generics"

This reverts commit 3953f85.

* Fix tests failing due to useSelect usage in AggregationPicker

* Omit aggregation options converting expressions to legacy

Fixes #36120.

* Remove temporary hack

* Get rid of props spread

* Migrate isExpressionEditorInitiallyOpen to MLv2

* Omit aggregation options converting expressions to legacy

Fixes #36120.

* Normalize legacy expressions as MBQL expressions

* Fix isExpressionEditorInitiallyOpen

* Update expressionName signature

* Pass props in ExpressionStep tests in a usual way

* Drop a conditional statement

* Bring back expression prop for backwards-compatibility

* Update ExpressionWidget validation & tests

* Bring back using expression in componentWillReceiveProps

* Bring back removed assertion

* Remove legacyQuery prop from AggregationPicker

* Add a test case for isExpressionEditorInitiallyOpen (which uses Lib.expressionName)

* Fix legacyQuery creation

* Add assertion for expression name

* Fix committing expression with done button

* Improve assertions in tests

* Make with-expression-name set the display-name of the clause

Fixes #36167.

This is needed to be able to set/change the display name of custom aggregation columns too.

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Add expression name assertion

* Unskip an e2e test

* Add expression name assertion

* Add expression name assertion

* Use displayInfo instead of displayName
- see #36203 (comment)

* Deprecate displayName in favor of displayInfo
- see https://metaboat.slack.com/archives/C0645JP1W81/p1701341786914219?thread_ts=1701335646.088359&cid=C0645JP1W81

* Use clearer notation

* Format code

* Use displayInfo instead of expressionName in tests

* Add isNamed attribute to ColumnDisplayInfo and ClauseDisplayInfo

* Use displayInfo instead of expressionName in AggregationPicker

* Drop expressionName

* Drop redundant cast

* Simplify isExpressionEditorInitiallyOpen interface

* Use display-info with :named? instead of expression-name

* Improve comment

* Add :named? to the schema of display-info

* Use conditional types for ExpressionWidget prop

* Use getNotebookStep

* Simplify condition

* Simplify assertions

* Use .lastCall

* Remove isNamed attribute from ColumnDisplayInfo

* Use .lastCall

* Fix typing

* Bring back legacyQuery prop to AggregationPicker

* Fix isExpressionEditorInitiallyOpen for new clauses

* Fix unit tests

* Remove wrong assertion

* Fix assertion

* Trigger a change

* Revert "Trigger a change"

This reverts commit 254913d.

* Fix assertion

* Allow FilterClause

* Drop legacyFilter usage from FilterPicker, FilterStep & QuestionFilters

* Update FilterPicker unit tests

* Remove unused function

* Fix types in unit test

* Remove redundant waitFor

* Update ColumnDisplayInfo type

* Revert changes to ColumnDisplayInfo, avoid using semanticType & effectiveType attributes

* Introduce NamedClause and CustomExpressionClause types

* Simplify assertions

* Remove casting from FilterPicker

* Rename NamedClause to CustomNameClause

* Exclude AggregationClause from FilterPicker's interfaces

* Avoid casting using generics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.Backend .metabase-lib Label for tracking all issues related to the shared CLJC metabase-lib .Team/QueryProcessor :hammer_and_wrench:
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants