Skip to content

Commit 1fa413a

Browse files
authored
[ML] Remove "8" prefixes from file structure finder timestamp formats (#38016)
In 7.x Java timestamp formats are the default timestamp format and there is no need to prefix them with "8". (The "8" prefix was used in 6.7 to distinguish Java timestamp formats from Joda timestamp formats.) This change removes the "8" prefixes from timestamp formats in the output of the ML file structure finder.
1 parent 5c58c25 commit 1fa413a

File tree

4 files changed

+10
-29
lines changed

4 files changed

+10
-29
lines changed

docs/reference/ml/apis/find-file-structure.asciidoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,11 +606,11 @@ If the request does not encounter errors, you receive the following result:
606606
},
607607
"tpep_dropoff_datetime" : {
608608
"type" : "date",
609-
"format" : "8yyyy-MM-dd HH:mm:ss"
609+
"format" : "yyyy-MM-dd HH:mm:ss"
610610
},
611611
"tpep_pickup_datetime" : {
612612
"type" : "date",
613-
"format" : "8yyyy-MM-dd HH:mm:ss"
613+
"format" : "yyyy-MM-dd HH:mm:ss"
614614
},
615615
"trip_distance" : {
616616
"type" : "double"
@@ -624,7 +624,7 @@ If the request does not encounter errors, you receive the following result:
624624
"field" : "tpep_pickup_datetime",
625625
"timezone" : "{{ beat.timezone }}",
626626
"formats" : [
627-
"8yyyy-MM-dd HH:mm:ss"
627+
"yyyy-MM-dd HH:mm:ss"
628628
]
629629
}
630630
}
@@ -1398,7 +1398,7 @@ this:
13981398
"field" : "timestamp",
13991399
"timezone" : "{{ beat.timezone }}",
14001400
"formats" : [
1401-
"8yyyy-MM-dd'T'HH:mm:ss,SSS"
1401+
"yyyy-MM-dd'T'HH:mm:ss,SSS"
14021402
]
14031403
}
14041404
},
@@ -1558,7 +1558,7 @@ this:
15581558
"field" : "timestamp",
15591559
"timezone" : "{{ beat.timezone }}",
15601560
"formats" : [
1561-
"8yyyy-MM-dd'T'HH:mm:ss,SSS"
1561+
"yyyy-MM-dd'T'HH:mm:ss,SSS"
15621562
]
15631563
}
15641564
},

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/filestructurefinder/FileStructureUtils.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public static Map<String, Object> makeIngestPipelineDefinition(String grokPatter
353353
if (needClientTimezone) {
354354
dateProcessorSettings.put("timezone", "{{ " + BEAT_TIMEZONE_FIELD + " }}");
355355
}
356-
dateProcessorSettings.put("formats", jodaBwcJavaTimestampFormatsForIngestPipeline(timestampFormats));
356+
dateProcessorSettings.put("formats", timestampFormats);
357357
processors.add(Collections.singletonMap("date", dateProcessorSettings));
358358
}
359359

@@ -365,19 +365,4 @@ public static Map<String, Object> makeIngestPipelineDefinition(String grokPatter
365365
pipeline.put(Pipeline.PROCESSORS_KEY, processors);
366366
return pipeline;
367367
}
368-
369-
// TODO: remove this method when Java time formats are the default
370-
static List<String> jodaBwcJavaTimestampFormatsForIngestPipeline(List<String> javaTimestampFormats) {
371-
return javaTimestampFormats.stream().map(format -> {
372-
switch (format) {
373-
case "ISO8601":
374-
case "UNIX_MS":
375-
case "UNIX":
376-
case "TAI64N":
377-
return format;
378-
default:
379-
return "8" + format;
380-
}
381-
}).collect(Collectors.toList());
382-
}
383368
}

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/filestructurefinder/TimestampFormatFinder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,7 @@ public Map<String, String> getEsDateMappingTypeWithFormat() {
472472
case "UNIX":
473473
return Stream.of("epoch_second");
474474
default:
475-
// TODO: remove the "8" prefix when Java time formats are the default
476-
return Stream.of("8" + format);
475+
return Stream.of(format);
477476
}
478477
}).collect(Collectors.joining("||"));
479478
if (formats.isEmpty() == false) {

x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/filestructurefinder/FileStructureUtilsTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,7 @@ public void testGuessMappingsAndCalculateFieldStats() {
331331
assertEquals(Collections.singletonMap(FileStructureUtils.MAPPING_TYPE_SETTING, "keyword"), mappings.get("foo"));
332332
Map<String, String> expectedTimeMapping = new HashMap<>();
333333
expectedTimeMapping.put(FileStructureUtils.MAPPING_TYPE_SETTING, "date");
334-
// TODO: remove the "8" prefix when Java time formats are the default
335-
expectedTimeMapping.put(FileStructureUtils.MAPPING_FORMAT_SETTING, "8" + "yyyy-MM-dd HH:mm:ss,SSS");
334+
expectedTimeMapping.put(FileStructureUtils.MAPPING_FORMAT_SETTING, "yyyy-MM-dd HH:mm:ss,SSS");
336335
assertEquals(expectedTimeMapping, mappings.get("time"));
337336
assertEquals(Collections.singletonMap(FileStructureUtils.MAPPING_TYPE_SETTING, "long"), mappings.get("bar"));
338337
assertNull(mappings.get("nothing"));
@@ -372,8 +371,7 @@ public void testMakeIngestPipelineDefinitionGivenStructuredWithTimestamp() {
372371
assertNotNull(dateProcessor);
373372
assertEquals(timestampField, dateProcessor.get("field"));
374373
assertEquals(needClientTimezone, dateProcessor.containsKey("timezone"));
375-
// TODO: remove the call to jodaBwcJavaTimestampFormatsForIngestPipeline() when Java time formats are the default
376-
assertEquals(FileStructureUtils.jodaBwcJavaTimestampFormatsForIngestPipeline(timestampFormats), dateProcessor.get("formats"));
374+
assertEquals(timestampFormats, dateProcessor.get("formats"));
377375

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

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

0 commit comments

Comments
 (0)