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] Remove "8" prefixes from file structure finder timestamp formats #38016

Merged
merged 3 commits into from
Feb 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/reference/ml/apis/find-file-structure.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,11 @@ If the request does not encounter errors, you receive the following result:
},
"tpep_dropoff_datetime" : {
"type" : "date",
"format" : "8yyyy-MM-dd HH:mm:ss"
"format" : "yyyy-MM-dd HH:mm:ss"
},
"tpep_pickup_datetime" : {
"type" : "date",
"format" : "8yyyy-MM-dd HH:mm:ss"
"format" : "yyyy-MM-dd HH:mm:ss"
},
"trip_distance" : {
"type" : "double"
Expand All @@ -624,7 +624,7 @@ If the request does not encounter errors, you receive the following result:
"field" : "tpep_pickup_datetime",
"timezone" : "{{ beat.timezone }}",
"formats" : [
"8yyyy-MM-dd HH:mm:ss"
"yyyy-MM-dd HH:mm:ss"
]
}
}
Expand Down Expand Up @@ -1398,7 +1398,7 @@ this:
"field" : "timestamp",
"timezone" : "{{ beat.timezone }}",
"formats" : [
"8yyyy-MM-dd'T'HH:mm:ss,SSS"
"yyyy-MM-dd'T'HH:mm:ss,SSS"
]
}
},
Expand Down Expand Up @@ -1558,7 +1558,7 @@ this:
"field" : "timestamp",
"timezone" : "{{ beat.timezone }}",
"formats" : [
"8yyyy-MM-dd'T'HH:mm:ss,SSS"
"yyyy-MM-dd'T'HH:mm:ss,SSS"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public static Map<String, Object> makeIngestPipelineDefinition(String grokPatter
if (needClientTimezone) {
dateProcessorSettings.put("timezone", "{{ " + BEAT_TIMEZONE_FIELD + " }}");
}
dateProcessorSettings.put("formats", jodaBwcJavaTimestampFormatsForIngestPipeline(timestampFormats));
dateProcessorSettings.put("formats", timestampFormats);
processors.add(Collections.singletonMap("date", dateProcessorSettings));
}

Expand All @@ -365,19 +365,4 @@ public static Map<String, Object> makeIngestPipelineDefinition(String grokPatter
pipeline.put(Pipeline.PROCESSORS_KEY, processors);
return pipeline;
}

// TODO: remove this method when Java time formats are the default
static List<String> jodaBwcJavaTimestampFormatsForIngestPipeline(List<String> javaTimestampFormats) {
return javaTimestampFormats.stream().map(format -> {
switch (format) {
case "ISO8601":
case "UNIX_MS":
case "UNIX":
case "TAI64N":
return format;
default:
return "8" + format;
}
}).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,7 @@ public Map<String, String> getEsDateMappingTypeWithFormat() {
case "UNIX":
return Stream.of("epoch_second");
default:
// TODO: remove the "8" prefix when Java time formats are the default
return Stream.of("8" + format);
return Stream.of(format);
}
}).collect(Collectors.joining("||"));
if (formats.isEmpty() == false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ public void testGuessMappingsAndCalculateFieldStats() {
assertEquals(Collections.singletonMap(FileStructureUtils.MAPPING_TYPE_SETTING, "keyword"), mappings.get("foo"));
Map<String, String> expectedTimeMapping = new HashMap<>();
expectedTimeMapping.put(FileStructureUtils.MAPPING_TYPE_SETTING, "date");
// TODO: remove the "8" prefix when Java time formats are the default
expectedTimeMapping.put(FileStructureUtils.MAPPING_FORMAT_SETTING, "8" + "yyyy-MM-dd HH:mm:ss,SSS");
expectedTimeMapping.put(FileStructureUtils.MAPPING_FORMAT_SETTING, "yyyy-MM-dd HH:mm:ss,SSS");
assertEquals(expectedTimeMapping, mappings.get("time"));
assertEquals(Collections.singletonMap(FileStructureUtils.MAPPING_TYPE_SETTING, "long"), mappings.get("bar"));
assertNull(mappings.get("nothing"));
Expand Down Expand Up @@ -372,8 +371,7 @@ public void testMakeIngestPipelineDefinitionGivenStructuredWithTimestamp() {
assertNotNull(dateProcessor);
assertEquals(timestampField, dateProcessor.get("field"));
assertEquals(needClientTimezone, dateProcessor.containsKey("timezone"));
// TODO: remove the call to jodaBwcJavaTimestampFormatsForIngestPipeline() when Java time formats are the default
assertEquals(FileStructureUtils.jodaBwcJavaTimestampFormatsForIngestPipeline(timestampFormats), dateProcessor.get("formats"));
assertEquals(timestampFormats, dateProcessor.get("formats"));

// After removing the two expected fields there should be nothing left in the pipeline
assertEquals(Collections.emptyMap(), pipeline);
Expand Down Expand Up @@ -406,8 +404,7 @@ public void testMakeIngestPipelineDefinitionGivenSemiStructured() {
assertNotNull(dateProcessor);
assertEquals(timestampField, dateProcessor.get("field"));
assertEquals(needClientTimezone, dateProcessor.containsKey("timezone"));
// TODO: remove the call to jodaBwcJavaTimestampFormatsForIngestPipeline() when Java time formats are the default
assertEquals(FileStructureUtils.jodaBwcJavaTimestampFormatsForIngestPipeline(timestampFormats), dateProcessor.get("formats"));
assertEquals(timestampFormats, dateProcessor.get("formats"));

Map<String, Object> removeProcessor = (Map<String, Object>) processors.get(2).get("remove");
assertNotNull(removeProcessor);
Expand Down