From 84d80864e7607120fb463078eeb441996d491516 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Wed, 29 May 2024 13:59:35 +0200 Subject: [PATCH 01/16] Create ES|QL where filters for ordinal charts --- .../public/components/xy_chart.tsx | 2 +- .../create_filters_from_value_click.ts | 47 ++++++++++++++++- .../data/public/actions/value_click_action.ts | 30 ++++++++--- src/plugins/text_based_languages/kibana.jsonc | 3 +- .../text_based_languages/public/plugin.ts | 22 +++++++- .../public/triggers/index.ts | 10 ++++ .../triggers/update_ESQL_query_action.ts | 52 +++++++++++++++++++ .../triggers/update_ESQL_query_helpers.tsx | 36 +++++++++++++ .../triggers/update_ESQL_query_trigger.ts | 21 ++++++++ .../text_based_languages/tsconfig.json | 3 +- 10 files changed, 213 insertions(+), 13 deletions(-) create mode 100644 src/plugins/text_based_languages/public/triggers/index.ts create mode 100644 src/plugins/text_based_languages/public/triggers/update_ESQL_query_action.ts create mode 100644 src/plugins/text_based_languages/public/triggers/update_ESQL_query_helpers.tsx create mode 100644 src/plugins/text_based_languages/public/triggers/update_ESQL_query_trigger.ts diff --git a/src/plugins/chart_expressions/expression_xy/public/components/xy_chart.tsx b/src/plugins/chart_expressions/expression_xy/public/components/xy_chart.tsx index 660e2c95bed2f..94c43309578a7 100644 --- a/src/plugins/chart_expressions/expression_xy/public/components/xy_chart.tsx +++ b/src/plugins/chart_expressions/expression_xy/public/components/xy_chart.tsx @@ -864,7 +864,7 @@ export function XYChart({ xDomain={xDomain} // enable brushing only for time charts, for both ES|QL and DSL queries onBrushEnd={interactive ? (brushHandler as BrushEndListener) : undefined} - onElementClick={interactive && !isEsqlMode ? clickHandler : undefined} + onElementClick={interactive ? clickHandler : undefined} legendAction={ interactive ? getLegendAction( diff --git a/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts b/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts index 5a3464d9aefea..fa6826177ed7c 100644 --- a/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts +++ b/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts @@ -8,7 +8,14 @@ import _ from 'lodash'; import { Datatable } from '@kbn/expressions-plugin/public'; -import { compareFilters, COMPARE_ALL_OPTIONS, Filter, toggleFilterNegated } from '@kbn/es-query'; +import { + compareFilters, + COMPARE_ALL_OPTIONS, + Filter, + toggleFilterNegated, + type AggregateQuery, +} from '@kbn/es-query'; +import { appendWhereClauseToESQLQuery } from '@kbn/esql-utils'; import { getIndexPatterns, getSearchService } from '../../services'; import { AggConfigSerialized } from '../../../common/search/aggs'; import { mapAndFlattenFilters } from '../../query'; @@ -22,6 +29,7 @@ interface ValueClickDataContext { }>; timeFieldName?: string; negate?: boolean; + query?: AggregateQuery; } /** @@ -148,3 +156,40 @@ export const createFiltersFromValueClickAction = async ({ compareFilters(a, b, COMPARE_ALL_OPTIONS) ); }; + +/** @public */ +export const appendFilterToESQLQueryFromValueClickAction = async ({ + data, + query, +}: ValueClickDataContext) => { + let queryWithFilter: string | undefined; + + await Promise.all( + data + .filter((point) => point) + .map(async (val) => { + const { table, column: columnIndex, row: rowIndex } = val; + if (table && table.columns && table.columns[columnIndex]) { + const column = table.columns[columnIndex]; + const value: unknown = rowIndex > -1 ? table.rows[rowIndex][column.id] : null; + + // Do not append in case of time series, for now. We need to find a way to compute the interval + // to create the time range filter correctly. The users can brush to update the time filter instead. + const isDate = column.meta?.type === 'date'; + + if (value === null || value === undefined || isDate || !query) return; + + const queryString = query.esql; + queryWithFilter = appendWhereClauseToESQLQuery( + queryString, + column.id, + value, + '+', + column.meta?.type + ); + } + }) + ); + + return queryWithFilter; +}; diff --git a/src/plugins/data/public/actions/value_click_action.ts b/src/plugins/data/public/actions/value_click_action.ts index b229ee5b07a04..38bf7cb9bebd1 100644 --- a/src/plugins/data/public/actions/value_click_action.ts +++ b/src/plugins/data/public/actions/value_click_action.ts @@ -6,11 +6,14 @@ * Side Public License, v 1. */ -import type { Filter } from '@kbn/es-query'; +import { Filter, AggregateQuery, isOfAggregateQueryType } from '@kbn/es-query'; import { Datatable } from '@kbn/expressions-plugin/public'; import { UiActionsActionDefinition, UiActionsStart } from '@kbn/ui-actions-plugin/public'; import { APPLY_FILTER_TRIGGER } from '../triggers'; -import { createFiltersFromValueClickAction } from './filters/create_filters_from_value_click'; +import { + createFiltersFromValueClickAction, + appendFilterToESQLQueryFromValueClickAction, +} from './filters/create_filters_from_value_click'; export type ValueClickActionContext = ValueClickContext; export const ACTION_VALUE_CLICK = 'ACTION_VALUE_CLICK'; @@ -28,6 +31,7 @@ export interface ValueClickContext { }>; timeFieldName?: string; negate?: boolean; + query?: AggregateQuery; }; } @@ -39,18 +43,30 @@ export function createValueClickActionDefinition( id: ACTION_VALUE_CLICK, shouldAutoExecute: async () => true, isCompatible: async (context: ValueClickContext) => { + if (context.data.query && isOfAggregateQueryType(context.data.query)) { + const queryString = await appendFilterToESQLQueryFromValueClickAction(context.data); + return queryString != null; + } const filters = await createFiltersFromValueClickAction(context.data); return filters.length > 0; }, execute: async (context: ValueClickActionContext) => { try { - const filters: Filter[] = await createFiltersFromValueClickAction(context.data); - if (filters.length > 0) { - await getStartServices().uiActions.getTrigger(APPLY_FILTER_TRIGGER).exec({ - filters, + if (context.data.query && isOfAggregateQueryType(context.data.query)) { + const queryString = await appendFilterToESQLQueryFromValueClickAction(context.data); + await getStartServices().uiActions.getTrigger('UPDATE_ESQL_QUERY_TRIGGER').exec({ embeddable: context.embeddable, - timeFieldName: context.data.timeFieldName, + queryString, }); + } else { + const filters: Filter[] = await createFiltersFromValueClickAction(context.data); + if (filters.length > 0) { + await getStartServices().uiActions.getTrigger(APPLY_FILTER_TRIGGER).exec({ + filters, + embeddable: context.embeddable, + timeFieldName: context.data.timeFieldName, + }); + } } } catch (e) { // eslint-disable-next-line no-console diff --git a/src/plugins/text_based_languages/kibana.jsonc b/src/plugins/text_based_languages/kibana.jsonc index 7e9aba22067e8..5bed408add15a 100644 --- a/src/plugins/text_based_languages/kibana.jsonc +++ b/src/plugins/text_based_languages/kibana.jsonc @@ -12,7 +12,8 @@ "requiredPlugins": [ "data", "expressions", - "dataViews" + "dataViews", + "uiActions", ], "requiredBundles": [ "kibanaReact", diff --git a/src/plugins/text_based_languages/public/plugin.ts b/src/plugins/text_based_languages/public/plugin.ts index dd6297750ae5b..841641c8fce25 100755 --- a/src/plugins/text_based_languages/public/plugin.ts +++ b/src/plugins/text_based_languages/public/plugin.ts @@ -9,27 +9,45 @@ import type { Plugin, CoreStart, CoreSetup } from '@kbn/core/public'; import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public'; import type { ExpressionsStart } from '@kbn/expressions-plugin/public'; +import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; import type { IndexManagementPluginSetup } from '@kbn/index-management'; +import type { UiActionsSetup, UiActionsStart } from '@kbn/ui-actions-plugin/public'; +import { + updateESQLQueryTrigger, + UpdateESQLQueryAction, + UPDATE_ESQL_QUERY_TRIGGER, +} from './triggers'; import { setKibanaServices } from './kibana_services'; interface TextBasedLanguagesPluginStart { dataViews: DataViewsPublicPluginStart; expressions: ExpressionsStart; + uiActions: UiActionsStart; + data: DataPublicPluginStart; } interface TextBasedLanguagesPluginSetup { indexManagement: IndexManagementPluginSetup; + uiActions: UiActionsSetup; } export class TextBasedLanguagesPlugin implements Plugin<{}, void> { private indexManagement?: IndexManagementPluginSetup; - public setup(_: CoreSetup, { indexManagement }: TextBasedLanguagesPluginSetup) { + public setup(_: CoreSetup, { indexManagement, uiActions }: TextBasedLanguagesPluginSetup) { this.indexManagement = indexManagement; + + uiActions.registerTrigger(updateESQLQueryTrigger); + return {}; } - public start(core: CoreStart, { dataViews, expressions }: TextBasedLanguagesPluginStart): void { + public start( + core: CoreStart, + { dataViews, expressions, data, uiActions }: TextBasedLanguagesPluginStart + ): void { + const appendESQLAction = new UpdateESQLQueryAction(data); + uiActions.addTriggerAction(UPDATE_ESQL_QUERY_TRIGGER, appendESQLAction); setKibanaServices(core, dataViews, expressions, this.indexManagement); } diff --git a/src/plugins/text_based_languages/public/triggers/index.ts b/src/plugins/text_based_languages/public/triggers/index.ts new file mode 100644 index 0000000000000..06ac87b051c60 --- /dev/null +++ b/src/plugins/text_based_languages/public/triggers/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export { updateESQLQueryTrigger, UPDATE_ESQL_QUERY_TRIGGER } from './update_ESQL_query_trigger'; +export { UpdateESQLQueryAction } from './update_ESQL_query_action'; diff --git a/src/plugins/text_based_languages/public/triggers/update_ESQL_query_action.ts b/src/plugins/text_based_languages/public/triggers/update_ESQL_query_action.ts new file mode 100644 index 0000000000000..807c0d86be8b9 --- /dev/null +++ b/src/plugins/text_based_languages/public/triggers/update_ESQL_query_action.ts @@ -0,0 +1,52 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ +import { i18n } from '@kbn/i18n'; +import type { IEmbeddable } from '@kbn/embeddable-plugin/public'; +import type { Action } from '@kbn/ui-actions-plugin/public'; +import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; + +const ACTION_UPDATE_ESQL_QUERY = 'ACTION_UPDATE_ESQL_QUERY'; + +interface Context { + embeddable: IEmbeddable; + queryString: string; +} + +export const getHelpersAsync = async () => await import('./update_ESQL_query_helpers'); + +export class UpdateESQLQueryAction implements Action { + public type = ACTION_UPDATE_ESQL_QUERY; + public id = ACTION_UPDATE_ESQL_QUERY; + public order = 50; + + constructor(protected readonly data: DataPublicPluginStart) {} + + public getDisplayName({ embeddable }: Context): string { + return i18n.translate('textBasedLanguages.updateESQLQueryLabel', { + defaultMessage: 'Update the ES|QL query in the editor', + }); + } + + public getIconType() { + return 'filter'; + } + + public async isCompatible({ embeddable }: Context) { + const { isActionCompatible } = await getHelpersAsync(); + return isActionCompatible(this.data); + } + + public async execute({ embeddable, queryString }: Context) { + const { executeAction } = await getHelpersAsync(); + return executeAction({ + embeddable, + queryString, + data: this.data, + }); + } +} diff --git a/src/plugins/text_based_languages/public/triggers/update_ESQL_query_helpers.tsx b/src/plugins/text_based_languages/public/triggers/update_ESQL_query_helpers.tsx new file mode 100644 index 0000000000000..bb4ee41f2afdd --- /dev/null +++ b/src/plugins/text_based_languages/public/triggers/update_ESQL_query_helpers.tsx @@ -0,0 +1,36 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ +import { IEmbeddable } from '@kbn/embeddable-plugin/public'; +import { IncompatibleActionError } from '@kbn/ui-actions-plugin/public'; +import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; +import { isOfAggregateQueryType } from '@kbn/es-query'; + +interface Context { + data: DataPublicPluginStart; + embeddable: IEmbeddable; + queryString: string; +} + +export async function isActionCompatible(data: DataPublicPluginStart) { + const { query } = data; + const currentQueryString = query.queryString.getQuery(); + // we want to make sure that the current query is an ES|QL query + return currentQueryString && isOfAggregateQueryType(currentQueryString); +} + +export async function executeAction({ embeddable, queryString, data }: Context) { + const isCompatibleAction = await isActionCompatible(data); + if (!isCompatibleAction) { + throw new IncompatibleActionError(); + } + + const { query } = data; + query.queryString.setQuery({ + esql: queryString, + }); +} diff --git a/src/plugins/text_based_languages/public/triggers/update_ESQL_query_trigger.ts b/src/plugins/text_based_languages/public/triggers/update_ESQL_query_trigger.ts new file mode 100644 index 0000000000000..3573cc0c4d6fc --- /dev/null +++ b/src/plugins/text_based_languages/public/triggers/update_ESQL_query_trigger.ts @@ -0,0 +1,21 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { i18n } from '@kbn/i18n'; +import { Trigger } from '@kbn/ui-actions-plugin/public'; + +export const UPDATE_ESQL_QUERY_TRIGGER = 'UPDATE_ESQL_QUERY_TRIGGER'; +export const updateESQLQueryTrigger: Trigger = { + id: UPDATE_ESQL_QUERY_TRIGGER, + title: i18n.translate('textBasedLanguages.triggers.updateEsqlQueryTrigger', { + defaultMessage: 'Update ES|QL query', + }), + description: i18n.translate('textBasedLanguages.triggers.updateEsqlQueryTriggerDescription', { + defaultMessage: 'Update ES|QL query with a new one', + }), +}; diff --git a/src/plugins/text_based_languages/tsconfig.json b/src/plugins/text_based_languages/tsconfig.json index 2cb4eddcbf7a0..3cdc289e3b029 100644 --- a/src/plugins/text_based_languages/tsconfig.json +++ b/src/plugins/text_based_languages/tsconfig.json @@ -18,7 +18,8 @@ "@kbn/index-management", "@kbn/i18n", "@kbn/config-schema", - "@kbn/esql-utils" + "@kbn/esql-utils", + "@kbn/ui-actions-plugin" ], "exclude": [ "target/**/*", From 4193552362e5a73f96bc8f2789ddfe0d826a913c Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Wed, 29 May 2024 15:08:23 +0200 Subject: [PATCH 02/16] Cleanup --- .../public/triggers/update_ESQL_query_action.ts | 11 ++++------- .../public/triggers/update_ESQL_query_helpers.tsx | 4 +--- .../public/triggers/update_ESQL_query_trigger.ts | 1 + 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/plugins/text_based_languages/public/triggers/update_ESQL_query_action.ts b/src/plugins/text_based_languages/public/triggers/update_ESQL_query_action.ts index 807c0d86be8b9..4aa7b015b366b 100644 --- a/src/plugins/text_based_languages/public/triggers/update_ESQL_query_action.ts +++ b/src/plugins/text_based_languages/public/triggers/update_ESQL_query_action.ts @@ -6,18 +6,16 @@ * Side Public License, v 1. */ import { i18n } from '@kbn/i18n'; -import type { IEmbeddable } from '@kbn/embeddable-plugin/public'; import type { Action } from '@kbn/ui-actions-plugin/public'; import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; const ACTION_UPDATE_ESQL_QUERY = 'ACTION_UPDATE_ESQL_QUERY'; interface Context { - embeddable: IEmbeddable; queryString: string; } -export const getHelpersAsync = async () => await import('./update_ESQL_query_helpers'); +export const getHelpersAsync = async () => await import('./update_esql_query_helpers'); export class UpdateESQLQueryAction implements Action { public type = ACTION_UPDATE_ESQL_QUERY; @@ -26,7 +24,7 @@ export class UpdateESQLQueryAction implements Action { constructor(protected readonly data: DataPublicPluginStart) {} - public getDisplayName({ embeddable }: Context): string { + public getDisplayName(): string { return i18n.translate('textBasedLanguages.updateESQLQueryLabel', { defaultMessage: 'Update the ES|QL query in the editor', }); @@ -36,15 +34,14 @@ export class UpdateESQLQueryAction implements Action { return 'filter'; } - public async isCompatible({ embeddable }: Context) { + public async isCompatible() { const { isActionCompatible } = await getHelpersAsync(); return isActionCompatible(this.data); } - public async execute({ embeddable, queryString }: Context) { + public async execute({ queryString }: Context) { const { executeAction } = await getHelpersAsync(); return executeAction({ - embeddable, queryString, data: this.data, }); diff --git a/src/plugins/text_based_languages/public/triggers/update_ESQL_query_helpers.tsx b/src/plugins/text_based_languages/public/triggers/update_ESQL_query_helpers.tsx index bb4ee41f2afdd..67276b1c0237f 100644 --- a/src/plugins/text_based_languages/public/triggers/update_ESQL_query_helpers.tsx +++ b/src/plugins/text_based_languages/public/triggers/update_ESQL_query_helpers.tsx @@ -5,14 +5,12 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import { IEmbeddable } from '@kbn/embeddable-plugin/public'; import { IncompatibleActionError } from '@kbn/ui-actions-plugin/public'; import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; import { isOfAggregateQueryType } from '@kbn/es-query'; interface Context { data: DataPublicPluginStart; - embeddable: IEmbeddable; queryString: string; } @@ -23,7 +21,7 @@ export async function isActionCompatible(data: DataPublicPluginStart) { return currentQueryString && isOfAggregateQueryType(currentQueryString); } -export async function executeAction({ embeddable, queryString, data }: Context) { +export async function executeAction({ queryString, data }: Context) { const isCompatibleAction = await isActionCompatible(data); if (!isCompatibleAction) { throw new IncompatibleActionError(); diff --git a/src/plugins/text_based_languages/public/triggers/update_ESQL_query_trigger.ts b/src/plugins/text_based_languages/public/triggers/update_ESQL_query_trigger.ts index 3573cc0c4d6fc..13164647607ef 100644 --- a/src/plugins/text_based_languages/public/triggers/update_ESQL_query_trigger.ts +++ b/src/plugins/text_based_languages/public/triggers/update_ESQL_query_trigger.ts @@ -10,6 +10,7 @@ import { i18n } from '@kbn/i18n'; import { Trigger } from '@kbn/ui-actions-plugin/public'; export const UPDATE_ESQL_QUERY_TRIGGER = 'UPDATE_ESQL_QUERY_TRIGGER'; + export const updateESQLQueryTrigger: Trigger = { id: UPDATE_ESQL_QUERY_TRIGGER, title: i18n.translate('textBasedLanguages.triggers.updateEsqlQueryTrigger', { From 4152d59972eb82b58438604fb3d64047a40febf1 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Wed, 29 May 2024 15:23:48 +0200 Subject: [PATCH 03/16] Update imports --- src/plugins/text_based_languages/public/triggers/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/text_based_languages/public/triggers/index.ts b/src/plugins/text_based_languages/public/triggers/index.ts index 06ac87b051c60..b5d69a82b37a3 100644 --- a/src/plugins/text_based_languages/public/triggers/index.ts +++ b/src/plugins/text_based_languages/public/triggers/index.ts @@ -6,5 +6,5 @@ * Side Public License, v 1. */ -export { updateESQLQueryTrigger, UPDATE_ESQL_QUERY_TRIGGER } from './update_ESQL_query_trigger'; -export { UpdateESQLQueryAction } from './update_ESQL_query_action'; +export { updateESQLQueryTrigger, UPDATE_ESQL_QUERY_TRIGGER } from './update_esql_query_trigger'; +export { UpdateESQLQueryAction } from './update_esql_query_action'; From 7768d51efbe97588bf68e5e7906763c33a0f42c7 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Wed, 29 May 2024 16:46:04 +0200 Subject: [PATCH 04/16] Fixes --- src/plugins/text_based_languages/public/triggers/index.ts | 2 +- ...update_ESQL_query_action.ts => update_esql_query_actions.ts} | 0 ...date_ESQL_query_helpers.tsx => update_esql_query_helpers.ts} | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename src/plugins/text_based_languages/public/triggers/{update_ESQL_query_action.ts => update_esql_query_actions.ts} (100%) rename src/plugins/text_based_languages/public/triggers/{update_ESQL_query_helpers.tsx => update_esql_query_helpers.ts} (100%) diff --git a/src/plugins/text_based_languages/public/triggers/index.ts b/src/plugins/text_based_languages/public/triggers/index.ts index b5d69a82b37a3..091971018adf3 100644 --- a/src/plugins/text_based_languages/public/triggers/index.ts +++ b/src/plugins/text_based_languages/public/triggers/index.ts @@ -7,4 +7,4 @@ */ export { updateESQLQueryTrigger, UPDATE_ESQL_QUERY_TRIGGER } from './update_esql_query_trigger'; -export { UpdateESQLQueryAction } from './update_esql_query_action'; +export { UpdateESQLQueryAction } from './update_esql_query_actions'; diff --git a/src/plugins/text_based_languages/public/triggers/update_ESQL_query_action.ts b/src/plugins/text_based_languages/public/triggers/update_esql_query_actions.ts similarity index 100% rename from src/plugins/text_based_languages/public/triggers/update_ESQL_query_action.ts rename to src/plugins/text_based_languages/public/triggers/update_esql_query_actions.ts diff --git a/src/plugins/text_based_languages/public/triggers/update_ESQL_query_helpers.tsx b/src/plugins/text_based_languages/public/triggers/update_esql_query_helpers.ts similarity index 100% rename from src/plugins/text_based_languages/public/triggers/update_ESQL_query_helpers.tsx rename to src/plugins/text_based_languages/public/triggers/update_esql_query_helpers.ts From 0cbd70e88013f6c063c6326e256cccf988a03058 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Wed, 29 May 2024 16:47:20 +0200 Subject: [PATCH 05/16] what is going on github --- ...{update_ESQL_query_trigger.ts => update_esql_query_trigger.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/plugins/text_based_languages/public/triggers/{update_ESQL_query_trigger.ts => update_esql_query_trigger.ts} (100%) diff --git a/src/plugins/text_based_languages/public/triggers/update_ESQL_query_trigger.ts b/src/plugins/text_based_languages/public/triggers/update_esql_query_trigger.ts similarity index 100% rename from src/plugins/text_based_languages/public/triggers/update_ESQL_query_trigger.ts rename to src/plugins/text_based_languages/public/triggers/update_esql_query_trigger.ts From 63e0328b300e65a8365ba1442aea0c705f467479 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 29 May 2024 15:00:34 +0000 Subject: [PATCH 06/16] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- src/plugins/text_based_languages/tsconfig.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/text_based_languages/tsconfig.json b/src/plugins/text_based_languages/tsconfig.json index 3cdc289e3b029..3c7b28567816b 100644 --- a/src/plugins/text_based_languages/tsconfig.json +++ b/src/plugins/text_based_languages/tsconfig.json @@ -19,7 +19,9 @@ "@kbn/i18n", "@kbn/config-schema", "@kbn/esql-utils", - "@kbn/ui-actions-plugin" + "@kbn/ui-actions-plugin", + "@kbn/data-plugin", + "@kbn/es-query" ], "exclude": [ "target/**/*", From f4c4bb9bf197e37abbe6ec7a26a3ebc65eb4af99 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 3 Jun 2024 05:37:20 +0000 Subject: [PATCH 07/16] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- src/plugins/data/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/data/tsconfig.json b/src/plugins/data/tsconfig.json index 530d6b7325c00..ea92ad9289b13 100644 --- a/src/plugins/data/tsconfig.json +++ b/src/plugins/data/tsconfig.json @@ -56,6 +56,7 @@ "@kbn/react-kibana-mount", "@kbn/search-types", "@kbn/safer-lodash-set", + "@kbn/esql-utils", ], "exclude": [ "target/**/*", From d42dac46a338784a433a802b3820e1f623bbc370 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Mon, 3 Jun 2024 10:48:11 +0200 Subject: [PATCH 08/16] Adds unit tests --- .../create_filters_from_value_click.test.ts | 210 ++++++++++++------ .../data/public/actions/value_click_action.ts | 2 + .../update_esql_query_actions.test.ts | 37 +++ 3 files changed, 179 insertions(+), 70 deletions(-) create mode 100644 src/plugins/text_based_languages/public/triggers/update_esql_query_actions.test.ts diff --git a/src/plugins/data/public/actions/filters/create_filters_from_value_click.test.ts b/src/plugins/data/public/actions/filters/create_filters_from_value_click.test.ts index 4bb80fe64134b..fab4d18af400b 100644 --- a/src/plugins/data/public/actions/filters/create_filters_from_value_click.test.ts +++ b/src/plugins/data/public/actions/filters/create_filters_from_value_click.test.ts @@ -9,7 +9,10 @@ import { DataViewsContract } from '@kbn/data-views-plugin/common'; import { dataPluginMock } from '../../mocks'; import { setIndexPatterns, setSearchService } from '../../services'; -import { createFiltersFromValueClickAction } from './create_filters_from_value_click'; +import { + createFiltersFromValueClickAction, + appendFilterToESQLQueryFromValueClickAction, +} from './create_filters_from_value_click'; import { FieldFormatsGetConfigFn, BytesFormat } from '@kbn/field-formats-plugin/common'; import { RangeFilter } from '@kbn/es-query'; @@ -17,89 +20,156 @@ const mockField = { name: 'bytes', filterable: true, }; +describe('createFiltersFromClickEvent', () => { + const dataStart = dataPluginMock.createStartContract(); + setSearchService(dataStart.search); + setIndexPatterns({ + ...dataStart.indexPatterns, + get: async () => ({ + id: 'logstash-*', + fields: { + getByName: () => mockField, + filter: () => [mockField], + }, + getFormatterForField: () => new BytesFormat({}, (() => {}) as FieldFormatsGetConfigFn), + }), + } as unknown as DataViewsContract); + describe('createFiltersFromValueClick', () => { + let dataPoints: Parameters[0]['data']; -describe('createFiltersFromValueClick', () => { - let dataPoints: Parameters[0]['data']; - - beforeEach(() => { - dataPoints = [ - { - table: { - columns: [ - { - name: 'test', - id: '1-1', - meta: { - type: 'date', - source: 'esaggs', - sourceParams: { - indexPatternId: 'logstash-*', - type: 'histogram', - params: { - field: 'bytes', - interval: 30, - otherBucket: true, + beforeEach(() => { + dataPoints = [ + { + table: { + columns: [ + { + name: 'test', + id: '1-1', + meta: { + type: 'date', + source: 'esaggs', + sourceParams: { + indexPatternId: 'logstash-*', + type: 'histogram', + params: { + field: 'bytes', + interval: 30, + otherBucket: true, + }, }, }, }, - }, - ], - rows: [ - { - '1-1': '2048', - }, - ], - }, - column: 0, - row: 0, - value: 'test', - }, - ]; - - const dataStart = dataPluginMock.createStartContract(); - setSearchService(dataStart.search); - setIndexPatterns({ - ...dataStart.indexPatterns, - get: async () => ({ - id: 'logstash-*', - fields: { - getByName: () => mockField, - filter: () => [mockField], + ], + rows: [ + { + '1-1': '2048', + }, + ], + }, + column: 0, + row: 0, + value: 'test', }, - getFormatterForField: () => new BytesFormat({}, (() => {}) as FieldFormatsGetConfigFn), - }), - } as unknown as DataViewsContract); - }); + ]; + }); + test('ignores event when value for rows is not provided', async () => { + dataPoints[0].table.rows[0]['1-1'] = null; + const filters = await createFiltersFromValueClickAction({ data: dataPoints }); - test('ignores event when value for rows is not provided', async () => { - dataPoints[0].table.rows[0]['1-1'] = null; - const filters = await createFiltersFromValueClickAction({ data: dataPoints }); + expect(filters.length).toEqual(0); + }); - expect(filters.length).toEqual(0); - }); + test('handles an event when aggregations type is a terms', async () => { + (dataPoints[0].table.columns[0].meta.sourceParams as any).type = 'terms'; + const filters = await createFiltersFromValueClickAction({ data: dataPoints }); - test('handles an event when aggregations type is a terms', async () => { - (dataPoints[0].table.columns[0].meta.sourceParams as any).type = 'terms'; - const filters = await createFiltersFromValueClickAction({ data: dataPoints }); + expect(filters.length).toEqual(1); + expect(filters[0].query?.match_phrase?.bytes).toEqual('2048'); + }); - expect(filters.length).toEqual(1); - expect(filters[0].query?.match_phrase?.bytes).toEqual('2048'); - }); + test('handles an event when aggregations type is not terms', async () => { + const filters = await createFiltersFromValueClickAction({ data: dataPoints }); - test('handles an event when aggregations type is not terms', async () => { - const filters = await createFiltersFromValueClickAction({ data: dataPoints }); + expect(filters.length).toEqual(1); - expect(filters.length).toEqual(1); + const [rangeFilter] = filters as RangeFilter[]; + expect(rangeFilter.query.range.bytes.gte).toEqual(2048); + expect(rangeFilter.query.range.bytes.lt).toEqual(2078); + }); - const [rangeFilter] = filters as RangeFilter[]; - expect(rangeFilter.query.range.bytes.gte).toEqual(2048); - expect(rangeFilter.query.range.bytes.lt).toEqual(2078); + test('handles non-unique filters', async () => { + const [point] = dataPoints; + const filters = await createFiltersFromValueClickAction({ data: [point, point] }); + + expect(filters.length).toEqual(1); + }); }); + describe('appendFilterToESQLQueryFromValueClickAction', () => { + let dataPoints: Parameters[0]['data']; + beforeEach(() => { + dataPoints = [ + { + table: { + columns: [ + { + name: 'columnA', + id: 'columnA', + meta: { + type: 'date', + }, + }, + ], + rows: [ + { + columnA: '2048', + }, + ], + }, + column: 0, + row: 0, + value: 'test', + }, + ]; + }); + test('should return null for date fields', async () => { + const queryString = await appendFilterToESQLQueryFromValueClickAction({ + data: dataPoints, + query: { esql: 'from meow' }, + }); + + expect(queryString).toBeUndefined(); + }); - test('handles non-unique filters', async () => { - const [point] = dataPoints; - const filters = await createFiltersFromValueClickAction({ data: [point, point] }); + test('should return null if no aggregate query is present', async () => { + dataPoints[0].table.columns[0] = { + name: 'test', + id: '1-1', + meta: { + type: 'string', + }, + }; + const queryString = await appendFilterToESQLQueryFromValueClickAction({ + data: dataPoints, + }); + + expect(queryString).toBeUndefined(); + }); + + test('should return the update query string', async () => { + dataPoints[0].table.columns[0] = { + name: 'columnA', + id: 'columnA', + meta: { + type: 'string', + }, + }; + const queryString = await appendFilterToESQLQueryFromValueClickAction({ + data: dataPoints, + query: { esql: 'from meow' }, + }); - expect(filters.length).toEqual(1); + expect(queryString).toEqual(`from meow +| where \`columnA\`=="2048"`); + }); }); }); diff --git a/src/plugins/data/public/actions/value_click_action.ts b/src/plugins/data/public/actions/value_click_action.ts index 38bf7cb9bebd1..1279dc7b0443b 100644 --- a/src/plugins/data/public/actions/value_click_action.ts +++ b/src/plugins/data/public/actions/value_click_action.ts @@ -53,6 +53,8 @@ export function createValueClickActionDefinition( execute: async (context: ValueClickActionContext) => { try { if (context.data.query && isOfAggregateQueryType(context.data.query)) { + // ES|QL charts have a different way of applying filters, + // they are appending a where clause to the query const queryString = await appendFilterToESQLQueryFromValueClickAction(context.data); await getStartServices().uiActions.getTrigger('UPDATE_ESQL_QUERY_TRIGGER').exec({ embeddable: context.embeddable, diff --git a/src/plugins/text_based_languages/public/triggers/update_esql_query_actions.test.ts b/src/plugins/text_based_languages/public/triggers/update_esql_query_actions.test.ts new file mode 100644 index 0000000000000..e1c95a3e2f5e5 --- /dev/null +++ b/src/plugins/text_based_languages/public/triggers/update_esql_query_actions.test.ts @@ -0,0 +1,37 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ +import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; +import { UpdateESQLQueryAction } from './update_esql_query_actions'; + +describe('update ES|QL query action', () => { + const dataMock = dataPluginMock.createStartContract(); + describe('compatibility check', () => { + it('is incompatible if no query is applied', async () => { + const updateQueryAction = new UpdateESQLQueryAction(dataMock); + const isCompatible = await updateQueryAction.isCompatible(); + + expect(isCompatible).toBeFalsy(); + }); + + it('is incompatible if query is not ES|QL', async () => { + dataMock.query.queryString.getQuery = jest.fn().mockReturnValue({ query: 'not esql' }); + const updateQueryAction = new UpdateESQLQueryAction(dataMock); + const isCompatible = await updateQueryAction.isCompatible(); + + expect(isCompatible).toBeFalsy(); + }); + + it('is compatible if query is ES|QL', async () => { + dataMock.query.queryString.getQuery = jest.fn().mockReturnValue({ esql: 'from meow' }); + const updateQueryAction = new UpdateESQLQueryAction(dataMock); + const isCompatible = await updateQueryAction.isCompatible(); + + expect(isCompatible).toBeTruthy(); + }); + }); +}); From 7cd1101ae4939f942e29c2d9cf20f3f7f00f9a4a Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Tue, 4 Jun 2024 13:03:06 +0200 Subject: [PATCH 09/16] Disable tooltip actions for partition and heatmap charts --- .../public/components/heatmap_component.tsx | 5 ++++- .../public/components/partition_vis_component.tsx | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.tsx b/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.tsx index d36f8f54b9365..c8ab912acc7b2 100644 --- a/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.tsx +++ b/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.tsx @@ -7,6 +7,7 @@ */ import React, { memo, FC, useMemo, useState, useCallback, useRef } from 'react'; +import { ESQL_TABLE_TYPE } from '@kbn/data-plugin/common'; import { Chart, ElementClickListener, @@ -253,7 +254,9 @@ export const HeatmapComponent: FC = memo( datatables: [formattedTable.table], }); - const hasTooltipActions = interactive; + const isEsqlMode = table?.meta?.type === ESQL_TABLE_TYPE; + + const hasTooltipActions = interactive && !isEsqlMode; const onElementClick = useCallback( (e: HeatmapElementEvent[]) => { diff --git a/src/plugins/chart_expressions/expression_partition_vis/public/components/partition_vis_component.tsx b/src/plugins/chart_expressions/expression_partition_vis/public/components/partition_vis_component.tsx index 855d32ccc312a..de0def30577a4 100644 --- a/src/plugins/chart_expressions/expression_partition_vis/public/components/partition_vis_component.tsx +++ b/src/plugins/chart_expressions/expression_partition_vis/public/components/partition_vis_component.tsx @@ -22,6 +22,7 @@ import { Tooltip, TooltipValue, } from '@elastic/charts'; +import { ESQL_TABLE_TYPE } from '@kbn/data-plugin/common'; import { i18n } from '@kbn/i18n'; import { useEuiTheme } from '@elastic/eui'; import type { PaletteRegistry } from '@kbn/coloring'; @@ -409,8 +410,9 @@ const PartitionVisComponent = (props: PartitionVisComponentProps) => { ? getColumnByAccessor(splitRow[0], visData.columns) : undefined; + const isEsqlMode = originalVisData?.meta?.type === ESQL_TABLE_TYPE; const hasTooltipActions = - interactive && bucketAccessors.filter((a) => a !== 'metric-name').length > 0; + interactive && !isEsqlMode && bucketAccessors.filter((a) => a !== 'metric-name').length > 0; const tooltip: TooltipProps = { ...(fixedViewPort ? { boundary: fixedViewPort } : {}), From da032207b07e4d42cd67192784431862bdc4dc1c Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Tue, 4 Jun 2024 13:04:49 +0200 Subject: [PATCH 10/16] nit --- .../public/actions/filters/create_filters_from_value_click.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts b/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts index fa6826177ed7c..44ee82db738b8 100644 --- a/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts +++ b/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts @@ -177,7 +177,7 @@ export const appendFilterToESQLQueryFromValueClickAction = async ({ // to create the time range filter correctly. The users can brush to update the time filter instead. const isDate = column.meta?.type === 'date'; - if (value === null || value === undefined || isDate || !query) return; + if (value == null || isDate || !query) return; const queryString = query.esql; queryWithFilter = appendWhereClauseToESQLQuery( From 06e70bffbf3bff073a8acbd76a3d506f26d1f439 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Thu, 6 Jun 2024 11:16:33 +0200 Subject: [PATCH 11/16] Remove unecessary async --- .../public/actions/filters/create_filters_from_value_click.ts | 4 ++-- src/plugins/data/public/actions/value_click_action.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts b/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts index 44ee82db738b8..3814731458452 100644 --- a/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts +++ b/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts @@ -158,13 +158,13 @@ export const createFiltersFromValueClickAction = async ({ }; /** @public */ -export const appendFilterToESQLQueryFromValueClickAction = async ({ +export const appendFilterToESQLQueryFromValueClickAction = ({ data, query, }: ValueClickDataContext) => { let queryWithFilter: string | undefined; - await Promise.all( + Promise.all( data .filter((point) => point) .map(async (val) => { diff --git a/src/plugins/data/public/actions/value_click_action.ts b/src/plugins/data/public/actions/value_click_action.ts index 1279dc7b0443b..b30358a91de7c 100644 --- a/src/plugins/data/public/actions/value_click_action.ts +++ b/src/plugins/data/public/actions/value_click_action.ts @@ -55,7 +55,7 @@ export function createValueClickActionDefinition( if (context.data.query && isOfAggregateQueryType(context.data.query)) { // ES|QL charts have a different way of applying filters, // they are appending a where clause to the query - const queryString = await appendFilterToESQLQueryFromValueClickAction(context.data); + const queryString = appendFilterToESQLQueryFromValueClickAction(context.data); await getStartServices().uiActions.getTrigger('UPDATE_ESQL_QUERY_TRIGGER').exec({ embeddable: context.embeddable, queryString, From ec359541da318457a1509bf19732a1269cc4ac4c Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Thu, 6 Jun 2024 11:23:56 +0200 Subject: [PATCH 12/16] Fix bug, use name instead of id --- .../public/actions/filters/create_filters_from_value_click.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts b/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts index 3814731458452..418d8080a3904 100644 --- a/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts +++ b/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts @@ -182,7 +182,7 @@ export const appendFilterToESQLQueryFromValueClickAction = ({ const queryString = query.esql; queryWithFilter = appendWhereClauseToESQLQuery( queryString, - column.id, + column.name, value, '+', column.meta?.type From 577c9ae3f36bcbf5f42047d97dae1d92e8c4b08f Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Thu, 6 Jun 2024 14:06:56 +0200 Subject: [PATCH 13/16] nity --- .../create_filters_from_value_click.ts | 45 ++++++++----------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts b/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts index 418d8080a3904..92151181a9409 100644 --- a/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts +++ b/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts @@ -163,33 +163,26 @@ export const appendFilterToESQLQueryFromValueClickAction = ({ query, }: ValueClickDataContext) => { let queryWithFilter: string | undefined; - - Promise.all( - data - .filter((point) => point) - .map(async (val) => { - const { table, column: columnIndex, row: rowIndex } = val; - if (table && table.columns && table.columns[columnIndex]) { - const column = table.columns[columnIndex]; - const value: unknown = rowIndex > -1 ? table.rows[rowIndex][column.id] : null; - - // Do not append in case of time series, for now. We need to find a way to compute the interval - // to create the time range filter correctly. The users can brush to update the time filter instead. - const isDate = column.meta?.type === 'date'; - - if (value == null || isDate || !query) return; - - const queryString = query.esql; - queryWithFilter = appendWhereClauseToESQLQuery( - queryString, - column.name, - value, - '+', - column.meta?.type - ); - } - }) + if (!query) { + return; + } + // Do not append in case of time series, for now. We need to find a way to compute the interval + // to create the time range filter correctly. The users can brush to update the time filter instead. + const metricPoints = data.filter( + (point) => point && point.table?.columns?.[point.column].meta?.type !== 'date' ); + if (!metricPoints.length) { + return; + } + const { table, column: columnIndex, row: rowIndex } = metricPoints[metricPoints.length - 1]; + if (table && table.columns && table.columns[columnIndex]) { + const column = table.columns[columnIndex]; + const value: unknown = rowIndex > -1 ? table.rows[rowIndex][column.id] : null; + if (value == null) { + return; + } + return appendWhereClauseToESQLQuery(query.esql, column.name, value, '+', column.meta?.type); + } return queryWithFilter; }; From a61f35156fa81b7fe7e8268f5fa4317ddad9fdd2 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Fri, 7 Jun 2024 08:03:41 +0200 Subject: [PATCH 14/16] Fix --- .../filters/create_filters_from_value_click.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts b/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts index 92151181a9409..b788f4d0b826c 100644 --- a/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts +++ b/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts @@ -162,19 +162,20 @@ export const appendFilterToESQLQueryFromValueClickAction = ({ data, query, }: ValueClickDataContext) => { - let queryWithFilter: string | undefined; if (!query) { return; } // Do not append in case of time series, for now. We need to find a way to compute the interval // to create the time range filter correctly. The users can brush to update the time filter instead. - const metricPoints = data.filter( - (point) => point && point.table?.columns?.[point.column].meta?.type !== 'date' - ); - if (!metricPoints.length) { + const dataPoints = data.filter((point) => { + return point && point.table?.columns?.[point.column]?.meta?.type !== 'date'; + }); + + if (!dataPoints.length) { return; } - const { table, column: columnIndex, row: rowIndex } = metricPoints[metricPoints.length - 1]; + const { table, column: columnIndex, row: rowIndex } = dataPoints[dataPoints.length - 1]; + if (table && table.columns && table.columns[columnIndex]) { const column = table.columns[columnIndex]; const value: unknown = rowIndex > -1 ? table.rows[rowIndex][column.id] : null; @@ -183,6 +184,4 @@ export const appendFilterToESQLQueryFromValueClickAction = ({ } return appendWhereClauseToESQLQuery(query.esql, column.name, value, '+', column.meta?.type); } - - return queryWithFilter; }; From 2533540cb43056fb31debf7d40ef863db5104f53 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Mon, 10 Jun 2024 07:53:43 +0200 Subject: [PATCH 15/16] Update src/plugins/data/public/actions/filters/create_filters_from_value_click.ts Co-authored-by: Lukas Olson --- .../public/actions/filters/create_filters_from_value_click.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts b/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts index b788f4d0b826c..5493937a19cbb 100644 --- a/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts +++ b/src/plugins/data/public/actions/filters/create_filters_from_value_click.ts @@ -176,7 +176,7 @@ export const appendFilterToESQLQueryFromValueClickAction = ({ } const { table, column: columnIndex, row: rowIndex } = dataPoints[dataPoints.length - 1]; - if (table && table.columns && table.columns[columnIndex]) { + if (table?.columns?.[columnIndex]) { const column = table.columns[columnIndex]; const value: unknown = rowIndex > -1 ? table.rows[rowIndex][column.id] : null; if (value == null) { From c1ba747b9d081ed7823c70319ce1ed92bb13ff25 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Mon, 10 Jun 2024 08:00:35 +0200 Subject: [PATCH 16/16] Remove embeddable --- src/plugins/data/public/actions/value_click_action.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/data/public/actions/value_click_action.ts b/src/plugins/data/public/actions/value_click_action.ts index b30358a91de7c..fd96f514688b8 100644 --- a/src/plugins/data/public/actions/value_click_action.ts +++ b/src/plugins/data/public/actions/value_click_action.ts @@ -57,7 +57,6 @@ export function createValueClickActionDefinition( // they are appending a where clause to the query const queryString = appendFilterToESQLQueryFromValueClickAction(context.data); await getStartServices().uiActions.getTrigger('UPDATE_ESQL_QUERY_TRIGGER').exec({ - embeddable: context.embeddable, queryString, }); } else {