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

Suggestions refactoring #145571

Open
Tracked by #167089
flash1293 opened this issue Nov 17, 2022 · 1 comment
Open
Tracked by #167089

Suggestions refactoring #145571

flash1293 opened this issue Nov 17, 2022 · 1 comment
Labels
Feature:Lens impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. loe:x-large Extra Large Level of Effort Team:Visualizations Visualization editors, elastic-charts and infrastructure technical debt Improvement of the software architecture and operational architecture

Comments

@flash1293
Copy link
Contributor

flash1293 commented Nov 17, 2022

Current state

Right now, suggestions are working this way:

  • A black-box function on the datasource is providing a list of possible tables it can create with some meta information per column
  • These are passed to all visualizations - a black box function per visualization is checking whether the current visualization is able to "consume" a given table by returning a state object for this configuration plus a score
  • The score is used to rank the potential matches and the best one is picked

This approach gives a lot of flexibility, no assumptions about what the datasource or the visualization can do is hardcoded - the only interface is the table data structure.

However, due to that a lot of responsibility is shifted to the suggestion black box functions for visualizations and datasources:

  • All columns need to be "consumed", the suggestion logic needs to make sure there is no stale reference left - otherwise this can lead to weird bugs for existing saved objects
  • It's very hard to implement a change in behavior across all chart types because it needs to be implemented in the suggestion black box of each visualization separately
  • The separation of concerns (just a table shape, nothing else) makes it easy to accidentally implement suggestions that are weird to the user during chart switches

Target state

To address the pain points from above, the following general architecture would make more sense:

Instead of operating on possible tables and how they map to visualization states, refactor the suggestion logic to operate on possible columns of a data table and visualization dimensions to map them to.

The new flow would look like this:

  • Datasource states which columns it can offer
  • Visualizations state which columns they can "consume" and which dimensions they have to fill (some mandatory, some optional)
  • A pattern matching engine (part of the frame) matches and scores both of them with a single algorithm
  • Datasource is informed about which columns to produce and which columns to drop
  • Visualization is information about which columns to map

Advantages

  • The "pattern matching" part is already happening in an indirect way as a part of the visualization suggestion functions - this change unifies it in a single place and makes it explicit which will make it more robust and easier to change in a consistent fashion
  • Much harder to "forget" about unmapped columns in the table because suggestion code needs to be written in an explicit way moddeled around dimensions
  • Editor frame is aware of dropped/added columns meta information which can be used for other features (e.g. showing this information to a user before making a change)
  • Navigation from vis to vis is always consistent based on a single set of rules instead of having different rules for each type of vis

Disadvantages

  • Assumes columns are independent of each other and each column can be dropped at any point - however this is not necessarily true in all cases
  • Some changes might be harder in the future because "ad-hoc" changes bolted on for a special case are much harder to express.
@flash1293 flash1293 added technical debt Improvement of the software architecture and operational architecture Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Lens labels Nov 17, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-visualizations @elastic/kibana-visualizations-external (Team:Visualizations)

@stratoula stratoula added impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. impact:needs-assessment Product and/or Engineering needs to evaluate the impact of the change. and removed impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. labels Dec 21, 2022
@timductive timductive added impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. loe:weeks and removed impact:needs-assessment Product and/or Engineering needs to evaluate the impact of the change. labels Feb 8, 2023
@lukasolson lukasolson added loe:x-large Extra Large Level of Effort and removed loe:weeks labels Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Lens impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. loe:x-large Extra Large Level of Effort Team:Visualizations Visualization editors, elastic-charts and infrastructure technical debt Improvement of the software architecture and operational architecture
Projects
None yet
Development

No branches or pull requests

7 participants