From 3e082b01a376e611cc4f884c3ed320119f7906aa Mon Sep 17 00:00:00 2001 From: Dinu John <86094133+dinujoh@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:50:08 -0600 Subject: [PATCH] Update documentation Signed-off-by: Dinu John <86094133+dinujoh@users.noreply.github.com> --- .../source/rds/datatype/impl/TemporalTypeHandler.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/data-prepper-plugins/rds-source/src/main/java/org/opensearch/dataprepper/plugins/source/rds/datatype/impl/TemporalTypeHandler.java b/data-prepper-plugins/rds-source/src/main/java/org/opensearch/dataprepper/plugins/source/rds/datatype/impl/TemporalTypeHandler.java index e8f0505998..d8e4fedd4b 100644 --- a/data-prepper-plugins/rds-source/src/main/java/org/opensearch/dataprepper/plugins/source/rds/datatype/impl/TemporalTypeHandler.java +++ b/data-prepper-plugins/rds-source/src/main/java/org/opensearch/dataprepper/plugins/source/rds/datatype/impl/TemporalTypeHandler.java @@ -72,7 +72,7 @@ public Long handle(final MySQLDataType columnType, final String columnName, fina private Long handleTime(final String timeStr) { try { // Try parsing as Unix timestamp first - final Long timeEpoch = parseDateTimeStrAsEpoch(timeStr); + final Long timeEpoch = parseDateTimeStrAsEpochMillis(timeStr); if (timeEpoch != null) return timeEpoch; final LocalTime time = LocalTime.parse(timeStr, TIME_FORMATTER); @@ -88,7 +88,7 @@ private Long handleTime(final String timeStr) { private Long handleDate(final String dateStr) { try { // Try parsing as Unix timestamp first - final Long dateEpoch = parseDateTimeStrAsEpoch(dateStr); + final Long dateEpoch = parseDateTimeStrAsEpochMillis(dateStr); if (dateEpoch != null) return dateEpoch; LocalDate date = LocalDate.parse(dateStr, DATE_FORMATTER); @@ -102,7 +102,7 @@ private Long handleDate(final String dateStr) { private Long handleDateTime(final String dateTimeStr) { try { - final Long dateTimeEpoch = parseDateTimeStrAsEpoch(dateTimeStr); + final Long dateTimeEpoch = parseDateTimeStrAsEpochMillis(dateTimeStr); if (dateTimeEpoch != null) return dateTimeEpoch; // Parse using standard MySQL datetime format @@ -114,7 +114,9 @@ private Long handleDateTime(final String dateTimeStr) { } } - private Long parseDateTimeStrAsEpoch(final String dateTimeStr) { + // Binlog reader converts temporal fields to epoch millis + // The Binlog reader is set with EventDeserializer.CompatibilityMode.DATE_AND_TIME_AS_LONG + private Long parseDateTimeStrAsEpochMillis(final String dateTimeStr) { // Try parsing as Unix timestamp first try { return Long.parseLong(dateTimeStr);