Skip to content

Commit

Permalink
[ML] Fix boolean cell values in analytics table result views and tran…
Browse files Browse the repository at this point in the history
…sforms wizard. (#62618)

Fixes the rendering of boolean values in table results views and transforms wizards:
- Fixed: Boolean cells in the transform wizard ended up being empty.
- Fixed: Boolean cells in regression/classification result table would render as Yes/No instead of true/false.
  • Loading branch information
walterra authored Apr 6, 2020
1 parent ee02df4 commit a7b3e55
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export const ResultsTable: FC<Props> = React.memo(
switch (type) {
case ES_FIELD_TYPES.BOOLEAN:
column.dataType = ES_FIELD_TYPES.BOOLEAN;
column.render = d => (d ? 'true' : 'false');
break;
case ES_FIELD_TYPES.DATE:
column.align = 'right';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export const ResultsTable: FC<Props> = React.memo(
switch (type) {
case ES_FIELD_TYPES.BOOLEAN:
column.dataType = ES_FIELD_TYPES.BOOLEAN;
column.render = d => (d ? 'true' : 'false');
break;
case ES_FIELD_TYPES.DATE:
column.align = 'right';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ export const PivotPreview: FC<PivotPreviewProps> = React.memo(
return formatHumanReadableDateTimeSeconds(moment(cellValue).unix() * 1000);
}

if (previewMappings.properties[columnId].type === ES_FIELD_TYPES.BOOLEAN) {
return cellValue ? 'true' : 'false';
}

return cellValue;
};
}, [pageData, pagination.pageIndex, pagination.pageSize, previewMappings.properties]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ export const SourceIndexPreview: React.FC<Props> = React.memo(({ indexPattern, q
let schema;

switch (field?.type) {
case KBN_FIELD_TYPES.BOOLEAN:
schema = 'boolean';
break;
case KBN_FIELD_TYPES.DATE:
schema = 'datetime';
break;
Expand Down Expand Up @@ -190,6 +193,10 @@ export const SourceIndexPreview: React.FC<Props> = React.memo(({ indexPattern, q
return formatHumanReadableDateTimeSeconds(moment(cellValue).unix() * 1000);
}

if (field?.type === KBN_FIELD_TYPES.BOOLEAN) {
return cellValue ? 'true' : 'false';
}

return cellValue;
};
}, [data, indexPattern.fields, pagination.pageIndex, pagination.pageSize]);
Expand Down

0 comments on commit a7b3e55

Please sign in to comment.