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

[BUG][Query enhancements] Discover state partially resets when switching between plugins #9264

Open
joshuali925 opened this issue Jan 23, 2025 · 0 comments
Labels
bug Something isn't working untriaged

Comments

@joshuali925
Copy link
Member

joshuali925 commented Jan 23, 2025

Describe the bug

When query enhancements is enabled, switching from Discover to Dashboard would set query language back to DQL, and switching back to Discover would reset the selected index pattern to the default one. This becomes problematic when there are no index patterns in the current workspace. It would show the previously selected dataset with an empty "SQL" query bar, but it is actually sending DSL requests to /internal/search/opensearch-with-long-numerals

To Reproduce
Steps to reproduce the behavior:

  1. Create a new workspace with a opensearch connection. Ensure there are no index patterns in this workspace
  2. Click on discover and select an index from the opensearch connection with SQL language
  3. Run some query like SELECT request,response FROM apachelog where response = '501' limit 2
  4. Click on Dashboards and click back to Discover
  5. See index is still selected, language says "OpenSearch SQL", and query bar is empty
  6. Now try to run the same SQL query, discover shows different results
  7. In network tab, it calls POST /w/czLj6e/internal/search/opensearch-with-long-numerals instead of /w/czLj6e/api/enhancements/search/sql

Expected behavior
UI appearance and underlying state should be consistent

OpenSearch Version
main

Dashboards Version
main

Plugins

none

Screenshots

Notice SQL query is inside DSL
Image

Host/Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Browser and version [e.g. 22]

Additional context

One root cause is in setQuery,

public setQuery = (query: Partial<Query>) => {
const curQuery = this.query$.getValue();
let newQuery = { ...curQuery, ...query };
if (!isEqual(curQuery, newQuery)) {

When there's no index pattern, on switching from Dashboard to Discover, it resets the query to default by passing query with dataset being undefined. The current logic will keep the original dataset in this case, but language still got reset to DQL. Now we have a index type dataset with incompatible language.

I've tried small effort fixes like

    if (!query.dataset) {
      newQuery.dataset = undefined;
    }

and the index is no longer selected, but clicking on "Run" still sends DSL queries to the apachelog index. Apparently there are more places causing issues and need to be fixed

@joshuali925 joshuali925 added bug Something isn't working untriaged labels Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged
Projects
None yet
Development

No branches or pull requests

1 participant