From a61f35156fa81b7fe7e8268f5fa4317ddad9fdd2 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Fri, 7 Jun 2024 08:03:41 +0200 Subject: [PATCH] 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; };