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

Migrate isStructured method references to MLv2 #37977

Merged
merged 3 commits into from
Jan 26, 2024

Conversation

nemanjaglumac
Copy link
Member

@nemanjaglumac nemanjaglumac commented Jan 22, 2024

This PR migrates isStructured() references to MLv2.
It also removes the method altogether from the Question prototype.

Resolves #37389

Copy link

github-actions bot commented Jan 22, 2024

Codenotify: Notifying subscribers in CODENOTIFY files for diff bb6a4d0...535a442.

Notify File(s)
@alxnddr frontend/src/metabase/visualizations/components/LeafletMap.jsx
frontend/src/metabase/visualizations/components/settings/ChartSettingTableColumns/ChartSettingTableColumns.tsx

Copy link

replay-io bot commented Jan 22, 2024

StatusIn Progress ↗︎ 39 / 52
Commit535a442
Results
⚠️ 3 Flaky
1644 Passed

@nemanjaglumac nemanjaglumac changed the base branch from master to qc-mlv2-is-editable January 24, 2024 12:20
Base automatically changed from qc-mlv2-is-editable to master January 24, 2024 12:49
@nemanjaglumac nemanjaglumac added the no-backport Do not backport this PR to any branch label Jan 24, 2024
@nemanjaglumac nemanjaglumac force-pushed the qc-mlv2-is-structured branch 2 times, most recently from 99c809e to 1511ae8 Compare January 25, 2024 11:49
@nemanjaglumac nemanjaglumac changed the base branch from master to fix-broken-audit January 25, 2024 12:49
Base automatically changed from fix-broken-audit to master January 25, 2024 12:54
@nemanjaglumac nemanjaglumac changed the title Migrate isStructured method references to MLv2 [WIP] Migrate isStructured method references to MLv2 Jan 25, 2024
@nemanjaglumac nemanjaglumac requested a review from a team January 25, 2024 15:00
nemanjaglumac added a commit that referenced this pull request Jan 25, 2024
This is a follow-up after #37977.
Related to #37953
Copy link
Contributor

@kamilmielnik kamilmielnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

Left some comments and a question inline.

Comment on lines +97 to +100
const isPreviousQuestionNative =
previousQuery && Lib.queryDisplayInfo(previousQuery).isNative;

if (isNative || isPreviousQuestionNative) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, when previousQuestion was undefined/null, !previousQuestion?.isStructured() evaluated to true. Now it evaluates to a falsy value. Not sure if it makes things better or worse, but to make it work exactly like before, we should do this:

Suggested change
const isPreviousQuestionNative =
previousQuery && Lib.queryDisplayInfo(previousQuery).isNative;
if (isNative || isPreviousQuestionNative) {
const isPreviousQuestionStructured =
previousQuery && !Lib.queryDisplayInfo(previousQuery).isNative;
if (isNative || !isPreviousQuestionStructured) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the original code before @kulyk rewrote it.
https://github.com/metabase/metabase/pull/18827/files#diff-7eae47ba62c31da65c448230eacac88be86470a204d450011acb631d7bb74144L80-L83

image

So I think we can safely assume that the intention was to make sure the both questions are structured.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, when previousQuestion was undefined/null, !previousQuestion?.isStructured() evaluated to true.

@kamilmielnik I'm 99% sure the older implementation (rewrite) made this assumption by mistake. Do you mind if I leave the code as is?

frontend/src/metabase/services.js Show resolved Hide resolved
@@ -494,8 +486,9 @@ class Question {

const hasSinglePk =
table?.fields?.filter(field => field.isPK())?.length === 1;
const isStructured = !Lib.queryDisplayInfo(this.query()).isNative;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some files we're introducing isStructured and in some files we're just plainly using !isNative. I think we should go with 1 approach:

  • we can get rid of isStructured and always use !isNative
  • we can fully embrace isStructured by adding it to Lib.queryDisplayInfo result

WDYT?


this is a non-blocking comment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm for the first: !isNative

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some weird CI failures that I couldn't reproduce locally, I moved this step to a separate PR.
#38199

Just as with #38123, this is another place where MLv2 invocation broke
because it didn't guard against the internal queries.
@nemanjaglumac nemanjaglumac merged commit 1dda54f into master Jan 26, 2024
107 checks passed
@nemanjaglumac nemanjaglumac deleted the qc-mlv2-is-structured branch January 26, 2024 18:05
Copy link

@nemanjaglumac Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone?

nemanjaglumac added a commit that referenced this pull request Jan 30, 2024
This is purely semantic change.
Please see this comment #37977 (comment)
nemanjaglumac added a commit that referenced this pull request Jan 30, 2024
This is a follow-up after #37977.
Related to #37953
nemanjaglumac added a commit that referenced this pull request Feb 1, 2024
* Tidy-up `isStructured` v1 utils

This is a follow-up after #37977.
Related to #37953

* Rename MLv1 helper from `isStructured` to `isNative`
npfitz pushed a commit that referenced this pull request Feb 1, 2024
* Tidy-up `isStructured` v1 utils

This is a follow-up after #37977.
Related to #37953

* Rename MLv1 helper from `isStructured` to `isNative`
npfitz pushed a commit that referenced this pull request Feb 5, 2024
* Migrate `isStructured` method references to MLv2

* Fix broken audit pages

Just as with #38123, this is another place where MLv2 invocation broke
because it didn't guard against the internal queries.

* Remove `isStructured()` method from the `Question` prototype
npfitz pushed a commit that referenced this pull request Feb 5, 2024
This is purely semantic change.
Please see this comment #37977 (comment)
npfitz pushed a commit that referenced this pull request Feb 5, 2024
* Tidy-up `isStructured` v1 utils

This is a follow-up after #37977.
Related to #37953

* Rename MLv1 helper from `isStructured` to `isNative`
sloansparger pushed a commit that referenced this pull request Feb 5, 2024
* Migrate `isStructured` method references to MLv2

* Fix broken audit pages

Just as with #38123, this is another place where MLv2 invocation broke
because it didn't guard against the internal queries.

* Remove `isStructured()` method from the `Question` prototype
sloansparger pushed a commit that referenced this pull request Feb 5, 2024
This is purely semantic change.
Please see this comment #37977 (comment)
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/QueryingComponents visual Run Percy visual testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MLv2] [FE] Use MLv2 displayInfo in isStructured, isNative, isQueryEditable
3 participants