Skip to content

Commit

Permalink
[ML] Add override for data which doesn't contain a time field (#147504)
Browse files Browse the repository at this point in the history
Adds a checkbox to the overrides flyout to allow the user to tell the
find structure endpoint that the data does not contain a time field.


![image](https://user-images.githubusercontent.com/22172091/207582663-a510083e-be75-4ab8-bf7e-c91d72734c6f.png)

If the original analysis of the data does not find a time field, this
checkbox is unchecked by default.

Closes #146700

Also removes the jest snapshot test for the override flyout as it isn't
very useful.
  • Loading branch information
jgowdyelastic authored Dec 16, 2022
1 parent 5047b05 commit d14bf59
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 434 deletions.
2 changes: 2 additions & 0 deletions x-pack/plugins/data_visualizer/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export const MAX_FILE_SIZE_BYTES = 104857600; // 100MB
export const ABSOLUTE_MAX_FILE_SIZE_BYTES = 1073741274; // 1GB
export const FILE_SIZE_DISPLAY_FORMAT = '0,0.[0] b';

export const NO_TIME_FORMAT = 'null';

// Value to use in the Elasticsearch index mapping meta data to identify the
// index as having been created by the File Data Visualizer.
export const INDEX_META_DATA_CREATED_BY = 'file-data-visualizer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { isEqual } from 'lodash';
import type { AnalysisResult, InputOverrides } from '@kbn/file-upload-plugin/common';
import { MB, FILE_FORMATS } from '../../../../../common/constants';
import { MB, FILE_FORMATS, NO_TIME_FORMAT } from '../../../../../common/constants';

export const DEFAULT_LINES_TO_SAMPLE = 1000;
const UPLOAD_SIZE_MB = 5;
Expand Down Expand Up @@ -117,10 +117,15 @@ export function createUrlOverrides(overrides: InputOverrides, originalSettings:
}

export function processResults({ results, overrides }: AnalysisResult) {
const timestampFormat =
results.java_timestamp_formats !== undefined && results.java_timestamp_formats.length
? results.java_timestamp_formats[0]
: undefined;
let timestampFormat;
if (
(overrides && overrides.timestamp_format === NO_TIME_FORMAT) ||
results.java_timestamp_formats === undefined
) {
timestampFormat = NO_TIME_FORMAT;
} else if (results.java_timestamp_formats.length) {
timestampFormat = results.java_timestamp_formats[0];
}

const linesToSample =
overrides !== undefined && overrides.lines_to_sample !== undefined
Expand Down
Loading

0 comments on commit d14bf59

Please sign in to comment.