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

Discover Bug Fixes #7948

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,32 @@
}

public getDefaultQuery() {
return {
query: this.getDefaultQueryString(),
language: this.getDefaultLanguage(),
...(this.uiSettings &&
this.uiSettings.get(UI_SETTINGS.QUERY_ENHANCEMENTS_ENABLED) && {
dataset: this.datasetService?.getDefault(),
}),
const defaultLanguageId = this.getDefaultLanguage();
const defaultQuery = this.getDefaultQueryString();
const defaultDataset = this.datasetService?.getDefault();

const query = {
query: defaultQuery,
language: defaultLanguageId,
};

if (
this.uiSettings &&
this.uiSettings.get(UI_SETTINGS.QUERY_ENHANCEMENTS_ENABLED) &&
defaultDataset &&
this.languageService
) {
const language = this.languageService.getLanguage(defaultLanguageId);
const newQuery = { ...query, dataset: defaultDataset };

Check warning on line 79 in src/plugins/data/public/query/query_string/query_string_manager.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/query/query_string/query_string_manager.ts#L78-L79

Added lines #L78 - L79 were not covered by tests
const newQueryString = language?.getQueryString(newQuery) || '';

return {

Check warning on line 82 in src/plugins/data/public/query/query_string/query_string_manager.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/query/query_string/query_string_manager.ts#L82

Added line #L82 was not covered by tests
...newQuery,
query: newQueryString,
};
}

return query;
}

public formatQuery(query: Query | string | undefined): Query {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/query_enhancements/server/utils/facet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class Facet {
const query: Query = request.body.query;
const { format, df } = request.body;
const params = {
body: { ...query },
body: { query: query.query },
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason why we removed the rest of the query object? I don't remember if the fetch() function for PPL and SQL use the rest of the object off the top of my head.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Before this change the request body that we used to send was of the following format

{
    query: {
      query: 'SELECT * FROM aaa* LIMIT 10',
      language: 'SQL',
      dataset: [Object],
      format: 'jdbc'
    },
    aggConfig: null,
    df: null
}

However the SQL plugins request only needs the following parameters.
image

Also we observed sending in the extra unrecognized parameters was causing bugs where the SQL Search not working for IndexPatterns with Wildcards in the name, therefore this PR aims to cleanup the request body that we send.

Copy link
Member

Choose a reason for hiding this comment

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

...(format !== 'jdbc' && { format }),
};
const clientId = query.dataset?.dataSource?.id ?? df?.meta?.queryConfig?.dataSourceId;
Expand Down
Loading