mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [[ML] Transforms: Limit the data grid result window (#196510)](https://github.com/elastic/kibana/pull/196510) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Robert Jaszczurek","email":"92210485+rbrtj@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-10-18T09:45:10Z","message":"[ML] Transforms: Limit the data grid result window (#196510)\n\n## Summary\r\n\r\nFix for: [#196101](https://github.com/elastic/kibana/issues/196101)\r\nAdded a limit for grid data, capping it at a max of `10000` documents,\r\nas any number above this triggers an error due to ES pagination\r\nlimitations. Since this is only a preview, displaying all the data in\r\nthe grid is unnecessary.\r\nAfter:\r\n\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [ ] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n\r\n---------\r\n\r\nCo-authored-by: István Zoltán Szabó <istvan.szabo@elastic.co>","sha":"592225dfb6ffefa2717b49479491231dec12ecf2","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix",":ml","v9.0.0","Team:ML","v8.16.0","backport:version","v8.17.0"],"title":"[ML] Transforms: Limit the data grid result window","number":196510,"url":"https://github.com/elastic/kibana/pull/196510","mergeCommit":{"message":"[ML] Transforms: Limit the data grid result window (#196510)\n\n## Summary\r\n\r\nFix for: [#196101](https://github.com/elastic/kibana/issues/196101)\r\nAdded a limit for grid data, capping it at a max of `10000` documents,\r\nas any number above this triggers an error due to ES pagination\r\nlimitations. Since this is only a preview, displaying all the data in\r\nthe grid is unnecessary.\r\nAfter:\r\n\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [ ] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n\r\n---------\r\n\r\nCo-authored-by: István Zoltán Szabó <istvan.szabo@elastic.co>","sha":"592225dfb6ffefa2717b49479491231dec12ecf2"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196510","number":196510,"mergeCommit":{"message":"[ML] Transforms: Limit the data grid result window (#196510)\n\n## Summary\r\n\r\nFix for: [#196101](https://github.com/elastic/kibana/issues/196101)\r\nAdded a limit for grid data, capping it at a max of `10000` documents,\r\nas any number above this triggers an error due to ES pagination\r\nlimitations. Since this is only a preview, displaying all the data in\r\nthe grid is unnecessary.\r\nAfter:\r\n\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [ ] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n\r\n---------\r\n\r\nCo-authored-by: István Zoltán Szabó <istvan.szabo@elastic.co>","sha":"592225dfb6ffefa2717b49479491231dec12ecf2"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/196829","number":196829,"state":"MERGED","mergeCommit":{"sha":"21a3625dd5933dcdc87195f5cb3bfa450a5287c9","message":"[8.16] [ML] Transforms: Limit the data grid result window (#196510) (#196829)\n\n# Backport\n\nThis will backport the following commits from `main` to `8.16`:\n- [[ML] Transforms: Limit the data grid result window\n(#196510)](https://github.com/elastic/kibana/pull/196510)\n\n<!--- Backport version: 9.4.3 -->\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sqren/backport)\n\n<!--BACKPORT [{\"author\":{\"name\":\"Robert\nJaszczurek\",\"email\":\"92210485+rbrtj@users.noreply.github.com\"},\"sourceCommit\":{\"committedDate\":\"2024-10-18T09:45:10Z\",\"message\":\"[ML]\nTransforms: Limit the data grid result window (#196510)\\n\\n##\nSummary\\r\\n\\r\\nFix for:\n[#196101](https://github.com/elastic/kibana/issues/196101)\\r\\nAdded a\nlimit for grid data, capping it at a max of `10000` documents,\\r\\nas any\nnumber above this triggers an error due to ES pagination\\r\\nlimitations.\nSince this is only a preview, displaying all the data in\\r\\nthe grid is\nunnecessary.\\r\\nAfter:\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n###\nChecklist\\r\\n\\r\\n- [ ] Any text added follows [EUI's\nwriting\\r\\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),\nuses\\r\\nsentence case text and includes\n[i18n\\r\\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by:\nIstván Zoltán Szabó\n<istvan.szabo@elastic.co>\",\"sha\":\"592225dfb6ffefa2717b49479491231dec12ecf2\",\"branchLabelMapping\":{\"^v9.0.0$\":\"main\",\"^v8.17.0$\":\"8.x\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"release_note:fix\",\":ml\",\"v9.0.0\",\"Team:ML\",\"v8.16.0\",\"backport:version\"],\"title\":\"[ML]\nTransforms: Limit the data grid result\nwindow\",\"number\":196510,\"url\":\"https://github.com/elastic/kibana/pull/196510\",\"mergeCommit\":{\"message\":\"[ML]\nTransforms: Limit the data grid result window (#196510)\\n\\n##\nSummary\\r\\n\\r\\nFix for:\n[#196101](https://github.com/elastic/kibana/issues/196101)\\r\\nAdded a\nlimit for grid data, capping it at a max of `10000` documents,\\r\\nas any\nnumber above this triggers an error due to ES pagination\\r\\nlimitations.\nSince this is only a preview, displaying all the data in\\r\\nthe grid is\nunnecessary.\\r\\nAfter:\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n###\nChecklist\\r\\n\\r\\n- [ ] Any text added follows [EUI's\nwriting\\r\\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),\nuses\\r\\nsentence case text and includes\n[i18n\\r\\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by:\nIstván Zoltán Szabó\n<istvan.szabo@elastic.co>\",\"sha\":\"592225dfb6ffefa2717b49479491231dec12ecf2\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[\"8.16\"],\"targetPullRequestStates\":[{\"branch\":\"main\",\"label\":\"v9.0.0\",\"branchLabelMappingKey\":\"^v9.0.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/196510\",\"number\":196510,\"mergeCommit\":{\"message\":\"[ML]\nTransforms: Limit the data grid result window (#196510)\\n\\n##\nSummary\\r\\n\\r\\nFix for:\n[#196101](https://github.com/elastic/kibana/issues/196101)\\r\\nAdded a\nlimit for grid data, capping it at a max of `10000` documents,\\r\\nas any\nnumber above this triggers an error due to ES pagination\\r\\nlimitations.\nSince this is only a preview, displaying all the data in\\r\\nthe grid is\nunnecessary.\\r\\nAfter:\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n###\nChecklist\\r\\n\\r\\n- [ ] Any text added follows [EUI's\nwriting\\r\\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),\nuses\\r\\nsentence case text and includes\n[i18n\\r\\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by:\nIstván Zoltán Szabó\n<istvan.szabo@elastic.co>\",\"sha\":\"592225dfb6ffefa2717b49479491231dec12ecf2\"}},{\"branch\":\"8.16\",\"label\":\"v8.16.0\",\"branchLabelMappingKey\":\"^v(\\\\d+).(\\\\d+).\\\\d+$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"}]}]\nBACKPORT-->\n\nCo-authored-by: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com>"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com>
This commit is contained in:
parent
6623f02f5a
commit
740930048b
5 changed files with 32 additions and 10 deletions
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -250,7 +250,7 @@ export interface UseDataGridReturnType {
|
|||
/**
|
||||
* Setter function for the row count info.
|
||||
*/
|
||||
setRowCountInfo: Dispatch<SetStateAction<RowCountInfo>>;
|
||||
setRowCountInfo: (info: RowCountInfo) => void;
|
||||
/**
|
||||
* Setter function for the sorting columns.
|
||||
*/
|
||||
|
|
|
@ -37,6 +37,8 @@ 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 { 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';
|
||||
|
@ -288,6 +290,14 @@ export const StepDefineForm: FC<StepDefineFormProps> = React.memo((props) => {
|
|||
};
|
||||
});
|
||||
|
||||
const rowCountInfoLabel = (
|
||||
<FormattedMessage
|
||||
id="xpack.transform.stepDefineForm.rowCountInfoLabel"
|
||||
defaultMessage="Results are limited to a maximum of {maxRowCount} for preview purposes"
|
||||
values={{ maxRowCount: MAX_ROW_COUNT }}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<div data-test-subj="transformStepDefineForm">
|
||||
<EuiForm>
|
||||
|
@ -467,6 +477,11 @@ export const StepDefineForm: FC<StepDefineFormProps> = React.memo((props) => {
|
|||
label={i18n.translate('xpack.transform.stepDefineForm.dataGridLabel', {
|
||||
defaultMessage: 'Source documents',
|
||||
})}
|
||||
labelAppend={
|
||||
indexPreviewProps.rowCount === MAX_ROW_COUNT && (
|
||||
<EuiText size="xs">{rowCountInfoLabel}</EuiText>
|
||||
)
|
||||
}
|
||||
>
|
||||
<DataGrid {...indexPreviewProps} />
|
||||
</EuiFormRow>
|
||||
|
@ -503,6 +518,11 @@ export const StepDefineForm: FC<StepDefineFormProps> = React.memo((props) => {
|
|||
label={i18n.translate('xpack.transform.stepDefineForm.previewLabel', {
|
||||
defaultMessage: 'Preview',
|
||||
})}
|
||||
labelAppend={
|
||||
previewProps.rowCount === MAX_ROW_COUNT && (
|
||||
<EuiText size="xs">{rowCountInfoLabel}</EuiText>
|
||||
)
|
||||
}
|
||||
>
|
||||
<>
|
||||
<DataGrid {...previewProps} />
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue