From 2a5e5fe13f3eb960fc0a9879c989962864bd31ba Mon Sep 17 00:00:00 2001 From: Dinu John <86094133+dinujoh@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:43:26 -0600 Subject: [PATCH] Add documentation Signed-off-by: Dinu John <86094133+dinujoh@users.noreply.github.com> --- .../rds/datatype/impl/TemporalTypeHandler.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 f0d5b4dbcb..c46a9a1cab 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 @@ -12,6 +12,22 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; +/** + * Handles MySQL temporal data types (DATE, TIME, DATETIME, YEAR) conversion between binlog and S3 export formats. + * + * MySQL binlog represents temporal types as follows: + * - DATE: long value representing days since epoch (1970-01-01) + * - TIME: long value representing milliseconds since epoch (1970-01-01 00:00:00) + * - DATETIME: long value representing microseconds since epoch (1970-01-01 00:00:00) + * - YEAR: 4-digit year value (Example: 2024) + * + * S3 export formats: + * - DATE: "yyyy-MM-dd" (Example: "2024-01-15") + * - TIME: "HH:mm:ss" (Example: "14:30:00") + * - DATETIME: "yyyy-MM-dd HH:mm:ss[.SSSSSS]" (Example: "2024-01-15 14:30:00.123456") + * Note: Fractional seconds are optional for DATETIME + * - YEAR: "yyyy" (Example: "2024") + */ public class TemporalTypeHandler implements DataTypeHandler { private static final String MYSQL_DATE_FORMAT = "yyyy-MM-dd"; private static final String MYSQL_TIME_FORMAT = "HH:mm:ss";