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] esql reduce field_caps usage #179120

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mattkime
Copy link
Contributor

Summary

Summarize your PR. If it involves visual changes include a screenshot or gif.

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

@mattkime mattkime changed the title just code notes [discover] esql reduce field_caps usage Mar 21, 2024
@@ -33,6 +33,7 @@ export async function getDataViewByTextBasedQueryLang(
currentDataView?.isPersisted() ||
indexPatternFromQuery !== currentDataView?.getIndexPattern()
) {
// I could use DataViewLazy here BUT this function returns a DataView - where is that DataView being used?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is identified in #169835 and is where my changes start but they seem to ripple outward. Someone with more experience in the discover state management could probably help me come up with a strategy.

Copy link
Member

Choose a reason for hiding this comment

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

I had a look at this, and we can't currently use DataViewLazy here, because this is setting the dataView in state which expects the DataView that's not so Lazy

So there's one thing in ES|QL that needs to be resolved differently. When the query is changed, the change of index pattern / data view is checked, and this can lead to loading time without any loading indication ... so we currently can't reduce field caps for ES|QL, but we could improve loading communication to the user, which happens here, when a query is submitted:

const fetchQuery = async (resetQuery?: boolean) => {
const query = getAppState().query;
const currentDataView = getSavedSearch().searchSource.getField('index');
if (isTextBasedQuery(query)) {
// this is where the dataView gets set to state, making it difficult to swap with dataViewLazy
const nextDataView = await getDataViewByTextBasedQueryLang(query, currentDataView, services);
if (nextDataView !== currentDataView) {
setDataView(nextDataView);
}
}
if (resetQuery) {
refetch$.next('reset');
} else {
refetch$.next(undefined);
}
return refetch$;
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants