mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [[ES|QL] Apply the timerange to the fields fetch in the editor (#208490)](https://github.com/elastic/kibana/pull/208490) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Stratoula Kalafateli","email":"efstratia.kalafateli@elastic.co"},"sourceCommit":{"committedDate":"2025-01-30T10:14:25Z","message":"[ES|QL] Apply the timerange to the fields fetch in the editor (#208490)\n\n## Summary\n\nProvides the timerange in the fetch fields api. This:\n\n- fixes the bug where the fields are not suggested when there are system\nnamed params such as `_tstart` and `_tend`\n- makes it more performant as now it checks for fields in the selected\ntimerange making it more performant (especially for data in the frozen\ntiers)\n\n<img width=\"834\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/ec0e6f87-3149-4a3f-a620-d7eab6a852a2\"\n/>","sha":"a63781a5ea26ef3c25fbf80dfc72a4b04a2be492","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","Feature:ES|QL","Team:ESQL","backport:version","v8.18.0"],"title":"[ES|QL] Apply the timerange to the fields fetch in the editor","number":208490,"url":"https://github.com/elastic/kibana/pull/208490","mergeCommit":{"message":"[ES|QL] Apply the timerange to the fields fetch in the editor (#208490)\n\n## Summary\n\nProvides the timerange in the fetch fields api. This:\n\n- fixes the bug where the fields are not suggested when there are system\nnamed params such as `_tstart` and `_tend`\n- makes it more performant as now it checks for fields in the selected\ntimerange making it more performant (especially for data in the frozen\ntiers)\n\n<img width=\"834\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/ec0e6f87-3149-4a3f-a620-d7eab6a852a2\"\n/>","sha":"a63781a5ea26ef3c25fbf80dfc72a4b04a2be492"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/208490","number":208490,"mergeCommit":{"message":"[ES|QL] Apply the timerange to the fields fetch in the editor (#208490)\n\n## Summary\n\nProvides the timerange in the fetch fields api. This:\n\n- fixes the bug where the fields are not suggested when there are system\nnamed params such as `_tstart` and `_tend`\n- makes it more performant as now it checks for fields in the selected\ntimerange making it more performant (especially for data in the frozen\ntiers)\n\n<img width=\"834\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/ec0e6f87-3149-4a3f-a620-d7eab6a852a2\"\n/>","sha":"a63781a5ea26ef3c25fbf80dfc72a4b04a2be492"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
This commit is contained in:
parent
14ad7170a9
commit
01b15a5f58
7 changed files with 21 additions and 5 deletions
|
@ -17,6 +17,7 @@ import { ESQLEditor } from './esql_editor';
|
|||
import type { ESQLEditorProps } from './types';
|
||||
import { ReactWrapper } from 'enzyme';
|
||||
import { coreMock } from '@kbn/core/server/mocks';
|
||||
import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
|
||||
|
||||
describe('ESQLEditor', () => {
|
||||
const uiConfig: Record<string, any> = {};
|
||||
|
@ -30,6 +31,7 @@ describe('ESQLEditor', () => {
|
|||
client: uiSettings,
|
||||
},
|
||||
core: coreMock.createStart(),
|
||||
data: dataPluginMock.createStartContract(),
|
||||
};
|
||||
|
||||
function renderESQLEditorComponent(testProps: ESQLEditorProps) {
|
||||
|
|
|
@ -23,7 +23,7 @@ import { isEqual } from 'lodash';
|
|||
import { CodeEditor, CodeEditorProps } from '@kbn/code-editor';
|
||||
import type { CoreStart } from '@kbn/core/public';
|
||||
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
|
||||
import type { AggregateQuery } from '@kbn/es-query';
|
||||
import type { AggregateQuery, TimeRange } from '@kbn/es-query';
|
||||
import type { ExpressionsStart } from '@kbn/expressions-plugin/public';
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import {
|
||||
|
@ -127,6 +127,7 @@ export const ESQLEditor = memo(function ESQLEditor({
|
|||
fieldsMetadata,
|
||||
uiSettings,
|
||||
uiActions,
|
||||
data,
|
||||
} = kibana.services;
|
||||
const darkMode = core.theme?.getTheme().darkMode;
|
||||
|
||||
|
@ -396,7 +397,7 @@ export const ESQLEditor = memo(function ESQLEditor({
|
|||
const { cache: esqlFieldsCache, memoizedFieldsFromESQL } = useMemo(() => {
|
||||
// need to store the timing of the first request so we can atomically clear the cache per query
|
||||
const fn = memoize(
|
||||
(...args: [{ esql: string }, ExpressionsStart, undefined, AbortController?]) => ({
|
||||
(...args: [{ esql: string }, ExpressionsStart, TimeRange, AbortController?]) => ({
|
||||
timestamp: Date.now(),
|
||||
result: fetchFieldsFromESQL(...args),
|
||||
}),
|
||||
|
@ -430,11 +431,12 @@ export const ESQLEditor = memo(function ESQLEditor({
|
|||
};
|
||||
// Check if there's a stale entry and clear it
|
||||
clearCacheWhenOld(esqlFieldsCache, esqlQuery.esql);
|
||||
const timeRange = data.query.timefilter.timefilter.getTime();
|
||||
try {
|
||||
const table = await memoizedFieldsFromESQL(
|
||||
esqlQuery,
|
||||
expressions,
|
||||
undefined,
|
||||
timeRange,
|
||||
abortController
|
||||
).result;
|
||||
const columns: ESQLRealField[] =
|
||||
|
@ -478,19 +480,21 @@ export const ESQLEditor = memo(function ESQLEditor({
|
|||
return callbacks;
|
||||
}, [
|
||||
fieldsMetadata,
|
||||
kibana.services?.esql?.getJoinIndicesAutocomplete,
|
||||
dataSourcesCache,
|
||||
query.esql,
|
||||
memoizedSources,
|
||||
dataViews,
|
||||
core,
|
||||
esqlFieldsCache,
|
||||
data.query.timefilter.timefilter,
|
||||
memoizedFieldsFromESQL,
|
||||
expressions,
|
||||
abortController,
|
||||
indexManagementApiService,
|
||||
histogramBarTarget,
|
||||
variablesService,
|
||||
kibana.services?.esql?.getJoinIndicesAutocomplete,
|
||||
variablesService?.esqlVariables,
|
||||
variablesService?.areSuggestionsEnabled,
|
||||
]);
|
||||
|
||||
const queryRunButtonProperties = useMemo(() => {
|
||||
|
|
|
@ -16,6 +16,7 @@ import type { FieldsMetadataPublicStart } from '@kbn/fields-metadata-plugin/publ
|
|||
import type { UsageCollectionStart } from '@kbn/usage-collection-plugin/public';
|
||||
import type { Storage } from '@kbn/kibana-utils-plugin/public';
|
||||
import type { UiActionsStart } from '@kbn/ui-actions-plugin/public';
|
||||
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
|
||||
import type { ESQLControlVariable } from '@kbn/esql-validation-autocomplete';
|
||||
|
||||
export interface ESQLEditorProps {
|
||||
|
@ -112,6 +113,7 @@ export interface EsqlPluginStartBase {
|
|||
export interface ESQLEditorDeps {
|
||||
core: CoreStart;
|
||||
dataViews: DataViewsPublicPluginStart;
|
||||
data: DataPublicPluginStart;
|
||||
expressions: ExpressionsStart;
|
||||
storage: Storage;
|
||||
uiActions: UiActionsStart;
|
||||
|
|
|
@ -14,6 +14,7 @@ import type { ExpressionsStart } from '@kbn/expressions-plugin/public';
|
|||
import type { Storage } from '@kbn/kibana-utils-plugin/public';
|
||||
import type { IndexManagementPluginSetup } from '@kbn/index-management-shared-types';
|
||||
import type { FieldsMetadataPublicStart } from '@kbn/fields-metadata-plugin/public';
|
||||
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
|
||||
import type { UsageCollectionStart } from '@kbn/usage-collection-plugin/public';
|
||||
import type { UiActionsStart } from '@kbn/ui-actions-plugin/public';
|
||||
import type { EsqlPluginStart } from './plugin';
|
||||
|
@ -23,6 +24,7 @@ export let core: CoreStart;
|
|||
interface ServiceDeps {
|
||||
core: CoreStart;
|
||||
dataViews: DataViewsPublicPluginStart;
|
||||
data: DataPublicPluginStart;
|
||||
expressions: ExpressionsStart;
|
||||
storage: Storage;
|
||||
uiActions: UiActionsStart;
|
||||
|
@ -49,6 +51,7 @@ export const setKibanaServices = (
|
|||
esql: EsqlPluginStart,
|
||||
kibanaCore: CoreStart,
|
||||
dataViews: DataViewsPublicPluginStart,
|
||||
data: DataPublicPluginStart,
|
||||
expressions: ExpressionsStart,
|
||||
storage: Storage,
|
||||
uiActions: UiActionsStart,
|
||||
|
@ -61,6 +64,7 @@ export const setKibanaServices = (
|
|||
core,
|
||||
dataViews,
|
||||
expressions,
|
||||
data,
|
||||
storage,
|
||||
uiActions,
|
||||
indexManagementApiService: indexManagement?.apiService,
|
||||
|
|
|
@ -103,6 +103,7 @@ export class EsqlPlugin implements Plugin<{}, EsqlPluginStart> {
|
|||
start,
|
||||
core,
|
||||
dataViews,
|
||||
data,
|
||||
expressions,
|
||||
storage,
|
||||
uiActions,
|
||||
|
|
|
@ -56,6 +56,7 @@ describe('ValueControlForm', () => {
|
|||
client: uiSettings,
|
||||
},
|
||||
core: coreMock.createStart(),
|
||||
data: dataMock,
|
||||
};
|
||||
|
||||
describe('Interval type', () => {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
import { setKibanaServices } from '@kbn/esql/public/kibana_services';
|
||||
import { coreMock } from '@kbn/core/public/mocks';
|
||||
import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks';
|
||||
import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
|
||||
import { expressionsPluginMock } from '@kbn/expressions-plugin/public/mocks';
|
||||
import { uiActionsPluginMock } from '@kbn/ui-actions-plugin/public/mocks';
|
||||
import type { Storage } from '@kbn/kibana-utils-plugin/public';
|
||||
|
@ -46,6 +47,7 @@ setKibanaServices(
|
|||
},
|
||||
coreMock.createStart(),
|
||||
dataViewPluginMocks.createStartContract(),
|
||||
dataPluginMock.createStartContract(),
|
||||
expressionsPluginMock.createStartContract(),
|
||||
storage,
|
||||
uiActionsPluginMock.createStartContract()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue