From 230d8cb8a5fcbf8bef96985e5451009039790b15 Mon Sep 17 00:00:00 2001 From: Julia Rechkunova Date: Thu, 28 Nov 2024 10:35:29 +0100 Subject: [PATCH] [Discover] Address the flaky histogram code (#201809) - Closes https://github.com/elastic/kibana/issues/201744 - Similar to https://github.com/elastic/kibana/issues/184600 ## Summary This PR fixes the issues with the transition from a data view without a time field to a data view with a time field. Previously reported error: ![management Index patterns on aliases discover verify hits should be able to disc-4da8c0b87362e3312cae00dc943a984acfda9af98d821decb6f48164eaca21ae](https://github.com/user-attachments/assets/652096ef-70c1-4394-a665-6b2b15d976ec) (cherry picked from commit f50b93c29004f8dac0fc6d1b44e6a8497a0cf2ea) --- .../public/services/lens_vis_service.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/unified_histogram/public/services/lens_vis_service.ts b/src/plugins/unified_histogram/public/services/lens_vis_service.ts index 5342ef4723b13..52968693ed650 100644 --- a/src/plugins/unified_histogram/public/services/lens_vis_service.ts +++ b/src/plugins/unified_histogram/public/services/lens_vis_service.ts @@ -329,8 +329,13 @@ export class LensVisService { queryParams: QueryParams; timeInterval: string | undefined; breakdownField: DataViewField | undefined; - }): Suggestion => { + }): Suggestion | undefined => { const { dataView } = queryParams; + + if (!dataView.isTimeBased() || !dataView.timeFieldName) { + return undefined; + } + const showBreakdown = breakdownField && fieldSupportsBreakdown(breakdownField); let columnOrder = ['date_column', 'count_column']; @@ -343,7 +348,7 @@ export class LensVisService { date_column: { dataType: 'date', isBucketed: true, - label: dataView.timeFieldName ?? '', + label: dataView.timeFieldName, operationType: 'date_histogram', scale: 'interval', sourceField: dataView.timeFieldName,