Skip to content

Commit

Permalink
Transforms/Data Frame Analytics: Fix populated fields sorting used fo…
Browse files Browse the repository at this point in the history
…r data grid columns. (elastic#98596)

Missed sorting the columns ids based on populated fields. If not all fields are populated in all documents equally, this could result in not correctly sorted columns, also resulting in flaky tests.
  • Loading branch information
walterra authored Apr 28, 2021
1 parent 5023dce commit 639f829
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ export const useIndexData = (
// Get all field names for each returned doc and flatten it
// to a list of unique field names used across all docs.
const allKibanaIndexPatternFields = getFieldsFromKibanaIndexPattern(indexPattern);
const populatedFields = [...new Set(docs.map(Object.keys).flat(1))].filter((d) =>
allKibanaIndexPatternFields.includes(d)
);
const populatedFields = [...new Set(docs.map(Object.keys).flat(1))]
.filter((d) => allKibanaIndexPatternFields.includes(d))
.sort();

setStatus(INDEX_STATUS.LOADED);
setIndexPatternFields(populatedFields);
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/transform/public/app/hooks/use_index_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ export const useIndexData = (
// Get all field names for each returned doc and flatten it
// to a list of unique field names used across all docs.
const allKibanaIndexPatternFields = getFieldsFromKibanaIndexPattern(indexPattern);
const populatedFields = [...new Set(docs.map(Object.keys).flat(1))].filter((d) =>
allKibanaIndexPatternFields.includes(d)
);
const populatedFields = [...new Set(docs.map(Object.keys).flat(1))]
.filter((d) => allKibanaIndexPatternFields.includes(d))
.sort();

setCcsWarning(isCrossClusterSearch && isMissingFields);
setStatus(INDEX_STATUS.LOADED);
Expand Down

0 comments on commit 639f829

Please sign in to comment.