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] Fix multi terms fields validation #126618

Merged
merged 17 commits into from
Mar 9, 2022
Merged

Conversation

dej611
Copy link
Contributor

@dej611 dej611 commented Mar 1, 2022

Summary

Fix #126343

This PR provides an in depth rewrite of the field validation logic, taking into accounts new multi-fields column and per field specific validation error.

The rewrite managed to reduce the amount of check/validation logic into a single function, and fix some bugs around multi terms and drag and drop combine action, together with better error messages.

Screenshot 2022-03-03 at 12 03 40

Screenshot 2022-03-03 at 12 18 28

Unsupported types are discarded for the combine action now:

multi_terms_invalid

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@dej611 dej611 added Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Lens labels Mar 1, 2022
@dej611
Copy link
Contributor Author

dej611 commented Mar 2, 2022

🕺 A little bit of dance as I thought to have applied the commit in the wrong branch :D

@dej611
Copy link
Contributor Author

dej611 commented Mar 3, 2022

@elasticmachine merge upstream

@dej611 dej611 added backport:skip This commit does not require backporting release_note:fix v8.2.0 labels Mar 3, 2022
@dej611 dej611 marked this pull request as ready for review March 3, 2022 16:48
@dej611 dej611 requested a review from a team as a code owner March 3, 2022 16:48
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors)

@dej611
Copy link
Contributor Author

dej611 commented Mar 4, 2022

@elasticmachine merge upstream

@dej611
Copy link
Contributor Author

dej611 commented Mar 7, 2022

@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 looks mostly good to me, but there are two things we should put into consideration:

  • Using date fields in a multi field terms was allowed previously, now we disallow it. This is a breaking change. Are we fine with this?
  • It's still weird it's possible to select the field from the list - maybe we should just not select the field if we know it's going to be invalid?

cc @ghudgins as these are product questions too

@dej611
Copy link
Contributor Author

dej611 commented Mar 7, 2022

  • Using date fields in a multi field terms was allowed previously, now we disallow it. This is a breaking change. Are we fine with this?

I thought about this as well, but given dates not being supported for single term Top values, finding them enabled on multi terms (for disabled fields on the dropdown) is a good hint for no support.
I guess it is possible to provide a runtime field workaround in this case?

It's still weird it's possible to select the field from the list - maybe we should just not select the field if we know it's going to be invalid?

Fair point. Should this be extended also to single term mode?

@flash1293
Copy link
Contributor

I guess it is possible to provide a runtime field workaround in this case?

Yeah, true, I don't expect it to become an issue

Fair point. Should this be extended also to single term mode?

No, in single term mode it's switching to date histogram which is a useful behavior.

@dej611
Copy link
Contributor Author

dej611 commented Mar 7, 2022

@flash1293 I've added some logic to remove fields with unsupported type when in multi-terms mode.

@dej611
Copy link
Contributor Author

dej611 commented Mar 8, 2022

@elasticmachine merge upstream

@dej611
Copy link
Contributor Author

dej611 commented Mar 9, 2022

@elasticmachine merge upstream

@flash1293
Copy link
Contributor

Sorry for the delay in review - it's close but in the single field case it should switch to date histogram automatically. At least that's what is happening for other operations, e.g. selecting a date field on "Intervals" switches to date histogram. If possible I would like to have this behaving consistent for the single field case.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
lens 751 752 +1

Async chunks

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

id before after diff
lens 1.1MB 1.1MB +903.0B

History

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

@dej611
Copy link
Contributor Author

dej611 commented Mar 9, 2022

Sorry for the delay in review - it's close but in the single field case it should switch to date histogram automatically. At least that's what is happening for other operations, e.g. selecting a date field on "Intervals" switches to date histogram. If possible I would like to have this behaving consistent for the single field case.

I think this switch behaviour has changed some time ago.
With this PR and in master I can reproduce it only on initial state when defined the bucketed dimensions. Once the dimension is defined picking a date field will no longer switch automatically in both branches.

On the other hand testing it on a 7.17 instance the behaviour still has the automatic switch. Perhaps it is worth a distinct issue for it?

@flash1293
Copy link
Contributor

I think it stopped working with the multi terms change (as the field change handling is now done on the terms operation level). Fine with splitting it out from this PR.

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.

LGTM for the rest of the behavior

@dej611
Copy link
Contributor Author

dej611 commented Mar 9, 2022

I think it stopped working with the multi terms change (as the field change handling is now done on the terms operation level). Fine with splitting it out from this PR.

Created #127258

@dej611 dej611 merged commit f5556f1 into elastic:main Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Lens release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] [FieldInputs] user should not be able to select "disabled" fields
5 participants