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

Use question metadata for generateQueryDescription #29331

Merged
merged 6 commits into from
Mar 22, 2023

Conversation

kulyk
Copy link
Member

@kulyk kulyk commented Mar 17, 2023

Patch for #29200

It seems like generateQueryDescription should be free to use its internal Metadata instance. We used to generate these descriptions in a separate function, so it made sense to pass it externally. But now we're calling the method for a question we'd like to get a description for. At that point, the question should have all the necessary metadata loaded.

The PR also removes the tableMetadata from a few query builder components. It seems like it was added to QueryBuilder's mapStateToProps only to be propagated down to the SaveQuestionModal.

Comment on lines 1573 to 1582
it("should work with multiple aggregations", () => {
const question = base_question.setDatasetQuery({
query: {
"source-table": ORDERS.id,
aggregation: [["count"], ["sum", ["field", 1, null]]],
aggregation: [["count"], ["sum", ["field", 6, null]]],
},
});
expect(question.generateQueryDescription(mockTableMetadata)).toEqual(
expect(question.generateQueryDescription()).toEqual(
"Orders, Count and Sum of Total",
);
Copy link
Member Author

Choose a reason for hiding this comment

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

base_question uses metadata from the sample database fixture. Field 1 there is actually "Created At", so changing the ID to 6 to correctly reference the "Total" column

@github-advanced-security
Copy link

You have successfully added a new CodeQL configuration .github/workflows/codeql.yml:analyze. As part of the setup process, we have scanned this repository and found 3 existing alerts. Please check the repository Security tab to see all alerts.

@kulyk kulyk changed the title 🚧 WIP | Use question metadata for generateQueryDescription Use question metadata for generateQueryDescription Mar 17, 2023
@kulyk kulyk requested review from camsaul, bshepherdson, ranquild and a team March 17, 2023 18:32
@kulyk kulyk self-assigned this Mar 17, 2023
Comment on lines -55 to -58
// DEPRECATED: replaced with `query`
tableMetadata: PropTypes.object,
datasetQuery: PropTypes.object,

Copy link
Member Author

Choose a reason for hiding this comment

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

Not used directly. Also there's no props spread, so child components don't seem to need them either

@@ -122,7 +121,6 @@ const mapStateToProps = (state, props) => {
databases: getDatabasesList(state),
nativeDatabases: getNativeDatabases(state),
tables: getTables(state),
tableMetadata: getTableMetadata(state),
Copy link
Member Author

Choose a reason for hiding this comment

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

SaveQuestionModal seems to be the only component that actually needed this

@codecov
Copy link

codecov bot commented Mar 17, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.01 ⚠️

Comparison is base (abc8116) 68.49% compared to head (24907f0) 68.48%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #29331      +/-   ##
==========================================
- Coverage   68.49%   68.48%   -0.01%     
==========================================
  Files        2790     2790              
  Lines       96508    96498      -10     
  Branches    12286    12286              
==========================================
- Hits        66101    66090      -11     
+ Misses      25204    25203       -1     
- Partials     5203     5205       +2     
Flag Coverage Δ
back-end 86.11% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
frontend/src/metabase-lib/Question.ts 63.50% <ø> (-0.77%) ⬇️
...tend/src/metabase/containers/SaveQuestionModal.jsx 82.05% <ø> (-0.45%) ⬇️
...mponents/AggregationPopover/AggregationPopover.jsx 5.12% <ø> (ø)
.../metabase/query_builder/components/QueryModals.jsx 0.00% <ø> (ø)
...metabase/query_builder/containers/QueryBuilder.jsx 0.00% <ø> (ø)

... and 2 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@deploysentinel
Copy link

deploysentinel bot commented Mar 17, 2023

No failed tests 🎉

Base automatically changed from MLv2-query-descriptions to master March 21, 2023 07:26
@kulyk kulyk force-pushed the anton/MLv2-query-descriptions-metadata branch from 360b5f1 to ee44d85 Compare March 21, 2023 12:22
@kulyk kulyk force-pushed the anton/MLv2-query-descriptions-metadata branch from ee44d85 to 24907f0 Compare March 21, 2023 12:53
@kulyk kulyk merged commit 4d9a4d3 into master Mar 22, 2023
@kulyk kulyk deleted the anton/MLv2-query-descriptions-metadata branch March 22, 2023 13:33
@darksciencebase darksciencebase added the .Team/QueryProcessor :hammer_and_wrench: label Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.Team/QueryProcessor :hammer_and_wrench:
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants