mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.16`: - [[Discover] Address the flaky histogram code (#201809)](https://github.com/elastic/kibana/pull/201809) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Julia Rechkunova","email":"julia.rechkunova@elastic.co"},"sourceCommit":{"committedDate":"2024-11-28T09:35:29Z","message":"[Discover] Address the flaky histogram code (#201809)\n\n- Closes https://github.com/elastic/kibana/issues/201744\r\n- Similar to https://github.com/elastic/kibana/issues/184600\r\n\r\n## Summary\r\n\r\nThis PR fixes the issues with the transition from a data view without a\r\ntime field to a data view with a time field.\r\n\r\nPreviously reported error:\r\n","sha":"f50b93c29004f8dac0fc6d1b44e6a8497a0cf2ea","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:DataDiscovery","v8.16.0","backport:version","v8.17.0","v8.18.0"],"title":"[Discover] Address the flaky histogram code","number":201809,"url":"https://github.com/elastic/kibana/pull/201809","mergeCommit":{"message":"[Discover] Address the flaky histogram code (#201809)\n\n- Closes https://github.com/elastic/kibana/issues/201744\r\n- Similar to https://github.com/elastic/kibana/issues/184600\r\n\r\n## Summary\r\n\r\nThis PR fixes the issues with the transition from a data view without a\r\ntime field to a data view with a time field.\r\n\r\nPreviously reported error:\r\n","sha":"f50b93c29004f8dac0fc6d1b44e6a8497a0cf2ea"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.17","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201809","number":201809,"mergeCommit":{"message":"[Discover] Address the flaky histogram code (#201809)\n\n- Closes https://github.com/elastic/kibana/issues/201744\r\n- Similar to https://github.com/elastic/kibana/issues/184600\r\n\r\n## Summary\r\n\r\nThis PR fixes the issues with the transition from a data view without a\r\ntime field to a data view with a time field.\r\n\r\nPreviously reported error:\r\n","sha":"f50b93c29004f8dac0fc6d1b44e6a8497a0cf2ea"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: Julia Rechkunova <julia.rechkunova@elastic.co>
This commit is contained in:
parent
5b38193933
commit
55bac33c26
2 changed files with 8 additions and 33 deletions
|
@ -10,7 +10,7 @@
|
|||
import { useEuiTheme } from '@elastic/eui';
|
||||
import { css } from '@emotion/react';
|
||||
import React, { useState } from 'react';
|
||||
import type { DataView, DataViewSpec } from '@kbn/data-views-plugin/public';
|
||||
import type { DataView } from '@kbn/data-views-plugin/public';
|
||||
import type { DefaultInspectorAdapters, Datatable } from '@kbn/expressions-plugin/common';
|
||||
import type { IKibanaSearchResponse } from '@kbn/search-types';
|
||||
import type { estypes } from '@elastic/elasticsearch';
|
||||
|
@ -59,32 +59,6 @@ export interface HistogramProps {
|
|||
withDefaultActions: EmbeddableComponentProps['withDefaultActions'];
|
||||
}
|
||||
|
||||
/**
|
||||
* To prevent flakiness in the chart, we need to ensure that the data view config is valid.
|
||||
* This requires that there are not multiple different data view ids in the given configuration.
|
||||
* @param dataView
|
||||
* @param visContext
|
||||
* @param adHocDataViews
|
||||
*/
|
||||
const checkValidDataViewConfig = (
|
||||
dataView: DataView,
|
||||
visContext: UnifiedHistogramVisContext,
|
||||
adHocDataViews: { [key: string]: DataViewSpec } | undefined
|
||||
) => {
|
||||
if (!dataView.id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!dataView.isPersisted() && !adHocDataViews?.[dataView.id]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dataView.id !== visContext.requestData.dataViewId) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
const computeTotalHits = (
|
||||
hasLensSuggestions: boolean,
|
||||
adapterTables:
|
||||
|
@ -230,10 +204,6 @@ export function Histogram({
|
|||
}
|
||||
`;
|
||||
|
||||
if (!checkValidDataViewConfig(dataView, visContext, lensProps.attributes.state.adHocDataViews)) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
|
|
|
@ -326,8 +326,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'];
|
||||
|
@ -340,7 +345,7 @@ export class LensVisService {
|
|||
date_column: {
|
||||
dataType: 'date',
|
||||
isBucketed: true,
|
||||
label: dataView.timeFieldName ?? '',
|
||||
label: dataView.timeFieldName,
|
||||
operationType: 'date_histogram',
|
||||
scale: 'interval',
|
||||
sourceField: dataView.timeFieldName,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue