From 55fcb654ee775badc690e4d991ca61b044d953cd Mon Sep 17 00:00:00 2001 From: rbrtj Date: Wed, 16 Oct 2024 11:17:25 +0200 Subject: [PATCH 1/5] limit max row count to 10000 --- .../ml/data_grid/hooks/use_data_grid.tsx | 14 ++++++++------ x-pack/packages/ml/data_grid/lib/common.ts | 4 ++-- x-pack/packages/ml/data_grid/lib/types.ts | 2 +- .../components/step_define/step_define_form.tsx | 16 ++++++++++++++++ 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/x-pack/packages/ml/data_grid/hooks/use_data_grid.tsx b/x-pack/packages/ml/data_grid/hooks/use_data_grid.tsx index dc87c68cc9b7c..f5ddb45642985 100644 --- a/x-pack/packages/ml/data_grid/hooks/use_data_grid.tsx +++ b/x-pack/packages/ml/data_grid/hooks/use_data_grid.tsx @@ -14,7 +14,7 @@ import { ES_CLIENT_TOTAL_HITS_RELATION } from '@kbn/ml-query-utils'; import { INDEX_STATUS } from '../lib/common'; import type { ChartData } from '../lib/field_histograms'; import { ColumnChart } from '../components/column_chart'; -import { COLUMN_CHART_DEFAULT_VISIBILITY_ROWS_THRESHOLD, INIT_MAX_COLUMNS } from '../lib/common'; +import { MAX_ROW_COUNT, INIT_MAX_COLUMNS } from '../lib/common'; import type { ChartsVisible, ColumnId, @@ -62,6 +62,11 @@ export const useDataGrid = ( const { rowCount, rowCountRelation } = rowCountInfo; + const setLimitedRowCountInfo = useCallback((info: RowCountInfo) => { + const limitedRowCount = Math.min(info.rowCount, MAX_ROW_COUNT); + setRowCountInfo({ rowCount: limitedRowCount, rowCountRelation: info.rowCountRelation }); + }, []); + const toggleChartVisibility = () => { if (chartsVisible !== undefined) { setChartsVisible(!chartsVisible); @@ -161,10 +166,7 @@ export const useDataGrid = ( // we decide whether to show or hide the charts by default. useEffect(() => { if (chartsVisible === undefined && rowCount > 0 && rowCountRelation !== undefined) { - setChartsVisible( - rowCount <= COLUMN_CHART_DEFAULT_VISIBILITY_ROWS_THRESHOLD && - rowCountRelation !== ES_CLIENT_TOTAL_HITS_RELATION.GTE - ); + setChartsVisible(rowCountRelation !== ES_CLIENT_TOTAL_HITS_RELATION.GTE); } }, [chartsVisible, rowCount, rowCountRelation]); @@ -189,7 +191,7 @@ export const useDataGrid = ( setErrorMessage, setNoDataMessage, setPagination, - setRowCountInfo, + setRowCountInfo: setLimitedRowCountInfo, setSortingColumns, setStatus, setTableItems, diff --git a/x-pack/packages/ml/data_grid/lib/common.ts b/x-pack/packages/ml/data_grid/lib/common.ts index 82c6cfa618174..bb20c8465dd4a 100644 --- a/x-pack/packages/ml/data_grid/lib/common.ts +++ b/x-pack/packages/ml/data_grid/lib/common.ts @@ -42,9 +42,9 @@ import type { DataGridItem, IndexPagination, RenderCellValue } from './types'; export const INIT_MAX_COLUMNS = 10; /** - * The default threshold value for the number of rows at which the column chart visibility is set to true. + * The default maximum row count value, set to 10000 due to ES limitations. */ -export const COLUMN_CHART_DEFAULT_VISIBILITY_ROWS_THRESHOLD = 10000; +export const MAX_ROW_COUNT = 10000; /** * Enum for index status diff --git a/x-pack/packages/ml/data_grid/lib/types.ts b/x-pack/packages/ml/data_grid/lib/types.ts index 4475d8572bcc8..a652e92d4c522 100644 --- a/x-pack/packages/ml/data_grid/lib/types.ts +++ b/x-pack/packages/ml/data_grid/lib/types.ts @@ -250,7 +250,7 @@ export interface UseDataGridReturnType { /** * Setter function for the row count info. */ - setRowCountInfo: Dispatch>; + setRowCountInfo: (info: RowCountInfo) => void; /** * Setter function for the sorting columns. */ diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx index bcee389d1d91b..ffd62b2a6d749 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx @@ -37,6 +37,7 @@ import { useStorage } from '@kbn/ml-local-storage'; import { useUrlState } from '@kbn/ml-url-state'; import { useFieldStatsFlyoutContext } from '@kbn/ml-field-stats-flyout'; +import { MAX_ROW_COUNT } from '@kbn/ml-data-grid/lib/common'; import type { PivotAggDict } from '../../../../../../common/types/pivot_aggs'; import type { PivotGroupByDict } from '../../../../../../common/types/pivot_group_by'; import { TRANSFORM_FUNCTION } from '../../../../../../common/constants'; @@ -288,6 +289,11 @@ export const StepDefineForm: FC = React.memo((props) => { }; }); + const rowCountInfoLabel = i18n.translate('xpack.transform.stepDefineForm.rowCountInfoLabel', { + defaultMessage: 'Results are being limited (max {maxRowCount}) for preview purposes', + values: { maxRowCount: MAX_ROW_COUNT }, + }); + return (
@@ -467,6 +473,11 @@ export const StepDefineForm: FC = React.memo((props) => { label={i18n.translate('xpack.transform.stepDefineForm.dataGridLabel', { defaultMessage: 'Source documents', })} + labelAppend={ + indexPreviewProps.rowCount === MAX_ROW_COUNT && ( + {rowCountInfoLabel} + ) + } > @@ -503,6 +514,11 @@ export const StepDefineForm: FC = React.memo((props) => { label={i18n.translate('xpack.transform.stepDefineForm.previewLabel', { defaultMessage: 'Preview', })} + labelAppend={ + previewProps.rowCount === MAX_ROW_COUNT && ( + {rowCountInfoLabel} + ) + } > <> From e5633b6e50f2533c1cf8775eddd0489498d45d48 Mon Sep 17 00:00:00 2001 From: rbrtj Date: Wed, 16 Oct 2024 14:21:59 +0200 Subject: [PATCH 2/5] update test --- .../runtime_mappings_saved_search/creation_runtime_mappings.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/apps/transform/creation/runtime_mappings_saved_search/creation_runtime_mappings.ts b/x-pack/test/functional/apps/transform/creation/runtime_mappings_saved_search/creation_runtime_mappings.ts index bbdf53b3eda5c..dc9c74dfa07a5 100644 --- a/x-pack/test/functional/apps/transform/creation/runtime_mappings_saved_search/creation_runtime_mappings.ts +++ b/x-pack/test/functional/apps/transform/creation/runtime_mappings_saved_search/creation_runtime_mappings.ts @@ -326,7 +326,7 @@ export default function ({ getService }: FtrProviderContext) { await transform.wizard.assertAdvancedQueryEditorSwitchCheckState(false); await transform.testExecution.logTestStep('enables the index preview histogram charts'); - await transform.wizard.enableIndexPreviewHistogramCharts(false); + await transform.wizard.enableIndexPreviewHistogramCharts(true); await transform.testExecution.logTestStep('displays the index preview histogram charts'); await transform.wizard.assertIndexPreviewHistogramCharts( testData.expected.histogramCharts From fcc0a9036ab97c5c5b50f9544912c589c835a3e0 Mon Sep 17 00:00:00 2001 From: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:23:18 +0200 Subject: [PATCH 3/5] update info label MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: István Zoltán Szabó --- .../components/step_define/step_define_form.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx index ffd62b2a6d749..1a996cdc10b31 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx @@ -290,7 +290,7 @@ export const StepDefineForm: FC = React.memo((props) => { }); const rowCountInfoLabel = i18n.translate('xpack.transform.stepDefineForm.rowCountInfoLabel', { - defaultMessage: 'Results are being limited (max {maxRowCount}) for preview purposes', + defaultMessage: 'Results are limited to a maximum of {maxRowCount} for preview purposes', values: { maxRowCount: MAX_ROW_COUNT }, }); From 314eec15d2beab13cd35216315d630b6f16003b6 Mon Sep 17 00:00:00 2001 From: rbrtj Date: Fri, 18 Oct 2024 09:56:21 +0200 Subject: [PATCH 4/5] use formatted message --- .../components/step_define/step_define_form.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx index 1a996cdc10b31..7c01e37247f81 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx @@ -76,6 +76,7 @@ import { useStepDefineForm } from './hooks/use_step_define_form'; import { TransformFunctionSelector } from './transform_function_selector'; import { LatestFunctionForm } from './latest_function_form'; import { PivotFunctionForm } from './pivot_function_form'; +import { FormattedMessage } from '@kbn/i18n-react'; const ALLOW_TIME_RANGE_ON_TRANSFORM_CONFIG = false; @@ -289,10 +290,13 @@ export const StepDefineForm: FC = React.memo((props) => { }; }); - const rowCountInfoLabel = i18n.translate('xpack.transform.stepDefineForm.rowCountInfoLabel', { - defaultMessage: 'Results are limited to a maximum of {maxRowCount} for preview purposes', - values: { maxRowCount: MAX_ROW_COUNT }, - }); + const rowCountInfoLabel = ( + + ); return (
From 7c3e6994000b3effd79d6e7d1b4a19119ffecfc4 Mon Sep 17 00:00:00 2001 From: rbrtj Date: Fri, 18 Oct 2024 09:57:33 +0200 Subject: [PATCH 5/5] eslint fix --- .../components/step_define/step_define_form.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx index 7c01e37247f81..92300d5580cbb 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx @@ -38,6 +38,7 @@ import { useUrlState } from '@kbn/ml-url-state'; import { useFieldStatsFlyoutContext } from '@kbn/ml-field-stats-flyout'; import { MAX_ROW_COUNT } from '@kbn/ml-data-grid/lib/common'; +import { FormattedMessage } from '@kbn/i18n-react'; import type { PivotAggDict } from '../../../../../../common/types/pivot_aggs'; import type { PivotGroupByDict } from '../../../../../../common/types/pivot_group_by'; import { TRANSFORM_FUNCTION } from '../../../../../../common/constants'; @@ -76,7 +77,6 @@ import { useStepDefineForm } from './hooks/use_step_define_form'; import { TransformFunctionSelector } from './transform_function_selector'; import { LatestFunctionForm } from './latest_function_form'; import { PivotFunctionForm } from './pivot_function_form'; -import { FormattedMessage } from '@kbn/i18n-react'; const ALLOW_TIME_RANGE_ON_TRANSFORM_CONFIG = false;