Skip to content

Commit

Permalink
remove unnecessary check
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra committed Oct 26, 2023
1 parent c93d3f8 commit 8f71729
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions x-pack/plugins/lens/common/expressions/datatable/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,10 @@
import type { Datatable } from '@kbn/expressions-plugin/common';
import { getOriginalId } from './transpose_helpers';

function isValidNumber(value: unknown): boolean {
return typeof value === 'number' || value == null;
}

export function isNumericFieldForDatatable(currentData: Datatable | undefined, accessor: string) {
const column = currentData?.columns.find(
(col) => col.id === accessor || getOriginalId(col.id) === accessor
);
const isNumeric = column?.meta.type === 'number';

return (
isNumeric &&
currentData?.rows.every((row) => {
const val = row[accessor];
return isValidNumber(val) || (Array.isArray(val) && val.every(isValidNumber));
})
);
return column?.meta.type === 'number';
}

0 comments on commit 8f71729

Please sign in to comment.