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

[ES|QL] ES|QL panel query doesn't change after user modifies the query, clicks on update and even after clicks on apply and close #183336

Open
bhavyarm opened this issue May 13, 2024 · 8 comments · May be fixed by #183561
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:Dashboard Dashboard related features Feature:ES|QL impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. loe:small Small Level of Effort Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas
Projects

Comments

@bhavyarm
Copy link
Contributor

Kibana version: 8.14.0 BC4

Elasticsearch version: 8.14.0

Browser version: chrome latest

Original install method (e.g. download page, yum, from source, etc.): from staging

Describe the bug: When user adds an ES|QL panel and changes the generic query to desired query and runs it - the panel query doesn't update. Also doesn't update even after they click on apply and close on edit ES|QL panel. Updates are visible only after user saves the dashboard and then clicks on edit again.

Steps to reproduce:

  1. Add an ES|QL panel to dashboard
  2. Modify the generic query and click update
  3. The panel query doesn't update though panel displays the results of the new es|al query
  4. Click apply and close on the ES|QL edit panel
  5. The panel query still doesn't apply
  6. Click save the dashboard and then edit again
  7. Now the query is updated

Screenshots (if relevant):

panel_filter.mp4
panel_filter_1.mp4
@bhavyarm bhavyarm added bug Fixes for quality problems that affect the customer experience Feature:Dashboard Dashboard related features Feature:ES|QL Team:ESQL ES|QL related features in Kibana labels May 13, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-esql (Team:ESQL)

@kibanamachine kibanamachine added loe:needs-research This issue requires some research before it can be worked on or estimated impact:needs-assessment Product and/or Engineering needs to evaluate the impact of the change. labels May 13, 2024
@kibanamachine kibanamachine added this to Inbox in Dashboard May 13, 2024
@stratoula stratoula added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas Team:Visualizations Visualization editors, elastic-charts and infrastructure and removed Team:ESQL ES|QL related features in Kibana labels May 14, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@elasticmachine
Copy link
Contributor

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

@stratoula
Copy link
Contributor

I am moving this to the presentation and visualizations teams, it seems that the panels filters do not listen the changes or something like that.

@ThomThomson ThomThomson added loe:small Small Level of Effort impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. and removed impact:needs-assessment Product and/or Engineering needs to evaluate the impact of the change. loe:needs-research This issue requires some research before it can be worked on or estimated Team:Visualizations Visualization editors, elastic-charts and infrastructure labels May 14, 2024
@ThomThomson
Copy link
Contributor

Confirming here that this is a Presentation team bug. It's likely caused by our embeddable refactor work. I.e. actions don't subscribe to every state change anymore, just the ones that are likely to cause them to update.

Should be a pretty straightforward fix.

@stratoula
Copy link
Contributor

Thanx Devon and team for your super fast response

@nreese
Copy link
Contributor

nreese commented May 15, 2024

@stratoula

I have diagnosed the problem and need help with picking the best solution. The problem is that there are 2 sources of visualization state in the LensEmbeddable, this.savedVis and input.attributes.

FiltersNotificationPopover is reading the query from api.query$?.value, where api is the LensEmbeddable instance.

LensEmbeddable.query$ gets updated when input changes and the new value is pulled from query$.next(embeddable.getQuery());

if (isFilterableEmbeddable(embeddable)) {
    embeddable.untilInitializationFinished().then(() => {
      filters$.next(embeddable.getFilters());
      query$.next(embeddable.getQuery());

      subscriptions.add(
        embeddable.getInput$().subscribe(() => {
          if (
            !compareFilters(
              embeddable.filters$.getValue() ?? [],
              embeddable.getFilters(),
              COMPARE_ALL_OPTIONS
            )
          ) {
            filters$.next(embeddable.getFilters());
          }
          if (!deepEqual(embeddable.query$.getValue() ?? [], embeddable.getQuery())) {
            query$.next(embeddable.getQuery());
          }
        })
      );
    });
  }

The LensEmbeddable implementation of getQuery pulls the query from this.savedVis?.state.query

  public getQuery() {
    return this.savedVis?.state.query;
  }

The problem is that this.savedVis is not updated when a users clicks run in the ESQL editor. Instead, the new visualization is stored like this.updateInput({ attributes: newViz })

async updateSuggestion(attrs: LensSavedObjectAttributes) {
    const viz = this.savedVis;
    const newViz = {
      ...viz,
      ...attrs,
    };
    this.updateInput({ attributes: newViz });
  }

What is the best solution to this problem? Should this.savedVis be updated when inline editing occurs? Should LensEmbeddable.getQuery be updated to read from input.attributes instead of this.savedVis?

Please advise.

@stratoula
Copy link
Contributor

Thanx for digging into this Nathan, I see. I think the cleanest solution is that the LensEmbeddable.getQuery should read from the input instead of the savedVis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Dashboard Dashboard related features Feature:ES|QL impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. loe:small Small Level of Effort Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas
Projects
No open projects
Dashboard
  
Inbox
6 participants