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

[Lens] Rename operations to map exposed names for Formula #94710

Merged
merged 19 commits into from
Mar 26, 2021

Conversation

dej611
Copy link
Contributor

@dej611 dej611 commented Mar 16, 2021

Summary

This PR renames the avg, cardinality and derivatives operation internally to respectively: average, unique_count, differences.
This change will help the user in the upcoming Formula PR to quickly reference functions based on the similarity of new names with the ones shown in the panel.

Changes:

  • 🚚 Renamed operations
  • ✅ Fixed broken unit tests
  • ✨ Migration
  • Fixed broken functional tests

Checklist

@dej611 dej611 added release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Mar 17, 2021
@dej611 dej611 marked this pull request as ready for review March 17, 2021 15:53
@dej611 dej611 requested a review from a team March 17, 2021 15:53
@dej611 dej611 requested a review from a team as a code owner March 17, 2021 15:53
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@dej611
Copy link
Contributor Author

dej611 commented Mar 17, 2021

@elasticmachine merge upstream

@qn895
Copy link
Member

qn895 commented Mar 18, 2021

Tested ML related changes and LGTM 👍

@dej611
Copy link
Contributor Author

dej611 commented Mar 18, 2021

@elasticmachine merge upstream

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

This PR breaks the types for buildColumn (didn't investigate how, maybe cyclical import?):

master
Screenshot 2021-03-22 at 11 24 13

your PR:
Screenshot 2021-03-22 at 11 24 19

@@ -76,7 +76,6 @@ function buildMetricOperation<T extends MetricColumn<string>>({
},
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a problem in this line: https://github.com/elastic/kibana/pull/94710/files#diff-e3c30f7e1cc23b9be6b4b2d689290e96925f48369dfcaa44d641014dfdc7bc80R68

The aggregation restriction mapping logic in

id: indexPattern.id!, // id exists for sure because we got index patterns by id
is using the Elasticsearch aggregation names, but now they are not in sync anymore (avg vs average). Aggregation restrictions for the average operation won't be loaded correctly anymore. We have to check aggregation restrictions for avg instead of average.

@@ -219,7 +219,7 @@ export const createMockedRestrictedIndexPattern = () => {
interval: 1000,
},
},
avg: {
average: {
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't happen - typeMeta is not controlled by Lens and will return avg

};

export const derivativeOperation: OperationDefinition<
DerivativeIndexPatternColumn,
'fullReference'
> = {
type: 'derivative',
type: 'differences',
Copy link
Contributor

Choose a reason for hiding this comment

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

If you create a constant for the name, why not use it here as well?

@dej611
Copy link
Contributor Author

dej611 commented Mar 22, 2021

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

merge conflict between base and head

@dej611 dej611 requested a review from flash1293 March 24, 2021 13:08
Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Tested and works fine. I built a visualization using differences, unique count and average in 7.12 and imported it - still works fine.

Just left one small nit that should be addressed

export const renameOperationsMapping: Record<string, GenericOperationDefinition['type']> = {
avg: 'average',
cardinality: 'unique_count',
derivative: 'differences',
Copy link
Contributor

Choose a reason for hiding this comment

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

Our derivative/differences implementation is not based on the Elasticsearch aggregation, it shouldn't show up here.

Copy link
Contributor Author

@dej611 dej611 Mar 24, 2021

Choose a reason for hiding this comment

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

I thought about it, but wanted to create a generic function for the renaming. Do you think this may lead to issues?

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 more concerned about this being confusing - Elasticsearch derivative and Lens differences do not share anything, so it doesn't make sense to map one to the other.

@dej611 dej611 added the auto-backport Deprecated - use backport:version if exact versions are needed label Mar 24, 2021
@dej611
Copy link
Contributor Author

dej611 commented Mar 24, 2021

This PR breaks the types for buildColumn (didn't investigate how, maybe cyclical import?):

I forgot to check this before, but it looks working now:

Screenshot 2021-03-24 at 17 24 58

Also it was giving me any as well when switched to this branch, but restarted the TS Server made it work properly.

@flash1293
Copy link
Contributor

I checked it as well and it worked for me. Might be just a bad cache on my side when I made the comment.

@dej611
Copy link
Contributor Author

dej611 commented Mar 25, 2021

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
lens 903.2KB 903.5KB +232.0B
ml 6.0MB 6.0MB +4.0B
total +236.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@dej611 dej611 merged commit 243a7f9 into elastic:master Mar 26, 2021
@dej611 dej611 deleted the fix/94150 branch March 26, 2021 10:54
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Mar 26, 2021
@kibanamachine
Copy link
Contributor

💚 Backport successful

7.x / #95500

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Feature:Lens release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.13.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Change the internal names of derivative, cardinality, avg to match public names
5 participants