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

[MBQL lib] Reject offset in expressions with no sort order #42662

Conversation

bshepherdson
Copy link
Contributor

Using offset as an aggregation is fine, but it doesn't work as an
expression unless the query has an order-by.

Part of #42318.

Copy link
Contributor Author

bshepherdson commented May 14, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @bshepherdson and the rest of your teammates on Graphite Graphite

@metabase-bot metabase-bot bot added the .Team/QueryProcessor :hammer_and_wrench: label May 14, 2024
@bshepherdson bshepherdson added the no-backport Do not backport this PR to any branch label May 14, 2024
@bshepherdson bshepherdson requested a review from snoe May 14, 2024 20:36
Copy link

replay-io bot commented May 14, 2024

Status Complete ↗︎
Commit 00bb26e
Results
⚠️ 4 Flaky
2504 Passed

@bshepherdson bshepherdson force-pushed the mblib-offset-diagnose-expression-require-order-by branch from 4253423 to 2eb1c3c Compare May 14, 2024 21:02
@bshepherdson bshepherdson force-pushed the mblib-offset-diagnose-expression-require-order-by branch from 2eb1c3c to 07ed12e Compare May 15, 2024 14:35
@bshepherdson bshepherdson changed the base branch from master to offset-custom-expressions May 15, 2024 18:54
- 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.
@bshepherdson bshepherdson force-pushed the mblib-offset-diagnose-expression-require-order-by branch from 07ed12e to 00bb26e Compare May 15, 2024 18:57
@bshepherdson bshepherdson merged commit 59b88af into offset-custom-expressions May 15, 2024
109 checks passed
@bshepherdson bshepherdson deleted the mblib-offset-diagnose-expression-require-order-by branch May 15, 2024 19:42
kamilmielnik added a commit that referenced this pull request May 21, 2024
* [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 🔧

* Oracle test update

* Improved Oracle test

* Test update 🔧

* 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 e63790b.

* Fix order of adjustments

---------

Co-authored-by: Cam Saul <github@camsaul.com>
Co-authored-by: Cam 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 #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: Braden Shepherdson <braden@metabase.com>
Co-authored-by: Cam Saul <github@camsaul.com>
Co-authored-by: Cam Saul <1455846+camsaul@users.noreply.github.com>
github-actions bot pushed a commit that referenced this pull request May 21, 2024
* [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 🔧

* Oracle test update

* Improved Oracle test

* Test update 🔧

* 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 e63790b.

* Fix order of adjustments

---------

Co-authored-by: Cam Saul <github@camsaul.com>
Co-authored-by: Cam 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 #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: Braden Shepherdson <braden@metabase.com>
Co-authored-by: Cam Saul <github@camsaul.com>
Co-authored-by: Cam Saul <1455846+camsaul@users.noreply.github.com>
metabase-bot bot added a commit that referenced this pull request May 21, 2024
* [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 🔧

* Oracle test update

* Improved Oracle test

* Test update 🔧

* 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 e63790b.

* Fix order of adjustments

---------




* 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 #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: Kamil Mielnik <kamil@kamilmielnik.com>
Co-authored-by: Braden Shepherdson <braden@metabase.com>
Co-authored-by: Cam Saul <github@camsaul.com>
Co-authored-by: Cam Saul <1455846+camsaul@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-backport Do not backport this PR to any branch .Team/QueryProcessor :hammer_and_wrench:
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants