Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Transforms: Data grid fixes. #59538

Merged

Conversation

walterra
Copy link
Contributor

@walterra walterra commented Mar 6, 2020

Summary

Part of #51288.
Fixes #59416.

  • Fixes data grid schemas to avoid crashing the page.
  • Fixes date formatting
  • Uses data grid for preview table in transform list.

Checklist

For maintainers

@walterra walterra self-assigned this Mar 6, 2020
@walterra walterra force-pushed the ml-transforms-data-grid-fix-date-formatting branch 2 times, most recently from 77aa174 to b760225 Compare March 6, 2020 16:13
@walterra walterra force-pushed the ml-transforms-data-grid-fix-date-formatting branch from b760225 to b68f9f3 Compare March 6, 2020 18:01
@walterra
Copy link
Contributor Author

walterra commented Mar 7, 2020

@elasticmachine merge upstream

@walterra walterra marked this pull request as ready for review March 9, 2020 09:57
@walterra walterra requested a review from a team as a code owner March 9, 2020 09:57
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@walterra walterra added the release_note:skip Skip the PR/issue when compiling release notes label Mar 9, 2020
let schema = 'string';
// Built-in values are ['boolean', 'currency', 'datetime', 'numeric', 'json']
// To fall back to the default string schema it needs to be undefined.
let schema;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is sorting not implemented for the source table yet? I can now pick a field(s) to sort by, but the table doesn't update after editing the sort (here I have chosen to sort by bytes (third column in the table):

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed a fix in c6b9430 - I thought I implemented that already in the original PR but seems it got lost somehow.

@peteharverson
Copy link
Contributor

peteharverson commented Mar 9, 2020

Probably not related to the changes in this PR, but are zero values being rendered as blank cells in the preview table? If I try and sort by DiskReadBytes.min, the table rows appear not to be sorted.

image

{
  "preview" : [
    {
      "instance" : "i-016431f5",
      "DiskReadBytes" : {
        "avg" : 1951.9113234591498,
        "min" : 0.0,
        "max" : 56524.8
      }
    },
    {
      "instance" : "i-0867b774",
      "DiskReadBytes" : {
        "avg" : 2.5243194709334E8,
        "min" : 6774784.0,
        "max" : 7.859675136E8
      }
    },
    {
      "instance" : "i-088147ac",
      "DiskReadBytes" : {
        "avg" : 538142.111900787,
        "min" : 0.0,
        "max" : 8.74315776E7
      }
    },

@walterra
Copy link
Contributor Author

walterra commented Mar 9, 2020

@peteharverson Fixed the empty cells in 760ae8a.

@peteharverson
Copy link
Contributor

Is it possible to prevent the user trying to sort on an object type field. For example, if you pick geoip.location in the Kibana ecommerce sample data set, the source table breaks:

image

@walterra
Copy link
Contributor Author

In 66161ff I improved the sorting related error handling:
When trying to sort on a json based field like geo fields you'll get a toast saying you can't sort on that field:

image

For other non-catchable error the messages is improved now to display the full error instead of just Bad Request (for example when trying to sort on a text based field instead of keyword):

image

I couldn't find a way to filter the list of available fields for sorting to be passed on to EuiDataGrid but asked the EUI team about it. If I hear back with a solution I'd suggest to improve that in a follow-up.

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested latest changes and generally LGTM.

Would be preferable if the table wasn't lost completely if for example the user tries to sort on a non-aggregatable text field. With the ecommerce data, if you pick the first category field to sort on, the table is lost and you have to start all over with creating the transform. Ideally we would look to hide fields that don't support sorting in the EuiDataGrid sorting popover.

Copy link
Contributor

@darnautov darnautov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGMT 👍 just a couple of nit comments

import { getNestedProperty } from './object_utils';

describe('object_utils', () => {
test('getNestedProperty()', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I believe it'd be better to have test per expect here because assertations are not related

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave it as is since this is a 1:1 copy of the same file we have in the ML plugin. I'd like to consolidate related files in a shared space for both plugins at some point then we can also refactor the these tests.

Comment on lines 114 to 127
const valid = sc.reduce((v, c) => {
if (v === false) return v;
const columnType = dataGridColumns.find(dgc => dgc.id === c.id);
const validSortingType = columnType?.schema !== 'json';
if (validSortingType === false) {
toastNotifications.addDanger(
i18n.translate('xpack.transform.sourceIndexPreview.invalidSortingColumnError', {
defaultMessage: `The column '{columnId}' cannot be used for sorting.`,
values: { columnId: c.id },
})
);
}
return validSortingType;
}, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find usage of reduce a bit confusing here:

  • it has a side effect inside
  • if one of the soring is invalid it doesn't check the others

It might be better to use find to get the first invalid one and show the toastNotifications after

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tweaked in d17b83b.

Comment on lines +29 to +31
const indexPatternTitle = Array.isArray(transformConfig.source.index)
? transformConfig.source.index.join(',')
: transformConfig.source.index;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

potentially might be an issue if the joint index patter does not exist (has a different order etc)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this can happen. in case there's no match or the source data has been deleted an error like this will be shown:

image

@walterra
Copy link
Contributor Author

@peteharverson I tweaked the behavior so the data grid will not be hidden when an error occurs:

image

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@walterra walterra merged commit ec1f46b into elastic:master Mar 10, 2020
@walterra walterra deleted the ml-transforms-data-grid-fix-date-formatting branch March 10, 2020 14:52
gmmorris added a commit to gmmorris/kibana that referenced this pull request Mar 10, 2020
* master:
  Add a retry to dashboard test for a sometimes slow async operation (elastic#59600)
  [Endpoint] Sample data generator for endpoint app (elastic#58936)
  [Vis Editor] Refactoring metrics axes (elastic#59135)
  [DOCS] Changed Discover app to Discover (elastic#59769)
  [Metrics Alerts] Add support for search query and groupBy on alerts (elastic#59388)
  Enhancement - EUICodeEditor for Visualize JSON  (elastic#58679)
  [ML] Transforms: Data grid fixes. (elastic#59538)
  [SIEM] Fix and consolidate handling of error responses in the client (elastic#59438)
  [Maps] convert tooltip classes to typescript (elastic#59589)
  [ML] Functional tests - re-activate date_nanos test (elastic#59649)
  Move canvas to use NP Expressions service (elastic#58387)
  Update misc dependencies (elastic#59542)
  [Unit Testing] Configure react-testing-library queries to use Kibana's data-test-subj instead of default data-testid (elastic#59445)
  [Console] Remove unused code (elastic#59554)
  [Logs / Metrics UI] Link handling / stop page reloads (elastic#58478)
  Add SavedObject management section registration in core  (elastic#59291)
walterra added a commit that referenced this pull request Mar 10, 2020
- Fixes data grid schemas to avoid crashing the page.
- Fixes date formatting.
- Uses data grid for preview table in transform list.

Co-authored-by: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Transforms ML transforms :ml refactoring release_note:skip Skip the PR/issue when compiling release notes v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ML] Transforms wizard page can crash if trying to add sort to a table
5 participants