diff --git a/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java b/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java index 5a35aadcae..af319c5e5a 100644 --- a/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java +++ b/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java @@ -106,12 +106,27 @@ public class DateTimeFunction { // Map used to determine format output for the get_format function private static final Table formats = ImmutableTable.builder() - //TODO: Add support for other formats - .put("date", "usa", "%m.%d.%Y") - .put("time", "usa", "%h:%i:%s %p") - .put("datetime", "usa", "%Y-%m-%d %H.%i.%s") - .put("timestamp", "usa", "%Y-%m-%d %H.%i.%s") - .build(); + .put("date", "usa", "%m.%d.%Y") + .put("date", "jis", "%Y-%m-%d") + .put("date", "iso", "%Y-%m-%d") + .put("date", "eur", "%d.%m.%Y") + .put("date", "internal", "%Y%m%d") + .put("datetime", "usa", "%Y-%m-%d %H.%i.%s") + .put("datetime", "jis", "%Y-%m-%d %H:%i:%s") + .put("datetime", "iso", "%Y-%m-%d %H:%i:%s") + .put("datetime", "eur", "%Y-%m-%d %H.%i.%s") + .put("datetime", "internal", "%Y%m%d%H%i%s") + .put("time", "usa", "%h:%i:%s %p") + .put("time", "jis", "%H:%i:%s") + .put("time", "iso", "%H:%i:%s") + .put("time", "eur", "%H.%i.%s") + .put("time", "internal", "%H%i%s") + .put("timestamp", "usa", "%Y-%m-%d %H.%i.%s") + .put("timestamp", "jis", "%Y-%m-%d %H:%i:%s") + .put("timestamp", "iso", "%Y-%m-%d %H:%i:%s") + .put("timestamp", "eur", "%Y-%m-%d %H.%i.%s") + .put("timestamp", "internal", "%Y%m%d%H%i%s") + .build(); /** * Register Date and Time Functions. diff --git a/core/src/test/java/org/opensearch/sql/expression/datetime/DateTimeFunctionTest.java b/core/src/test/java/org/opensearch/sql/expression/datetime/DateTimeFunctionTest.java index b993964b26..6198bbf2f0 100644 --- a/core/src/test/java/org/opensearch/sql/expression/datetime/DateTimeFunctionTest.java +++ b/core/src/test/java/org/opensearch/sql/expression/datetime/DateTimeFunctionTest.java @@ -681,9 +681,25 @@ public void from_days() { private static Stream getTestDataForGetFormat() { return Stream.of( Arguments.of("DATE", "USA", "%m.%d.%Y"), + Arguments.of("DATE", "JIS", "%Y-%m-%d"), + Arguments.of("DATE", "ISO", "%Y-%m-%d"), + Arguments.of("DATE", "EUR", "%d.%m.%Y"), + Arguments.of("DATE", "INTERNAL", "%Y%m%d"), Arguments.of("DATETIME", "USA", "%Y-%m-%d %H.%i.%s"), + Arguments.of("DATETIME", "JIS", "%Y-%m-%d %H:%i:%s"), + Arguments.of("DATETIME", "ISO", "%Y-%m-%d %H:%i:%s"), + Arguments.of("DATETIME", "EUR", "%Y-%m-%d %H.%i.%s"), + Arguments.of("DATETIME", "INTERNAL", "%Y%m%d%H%i%s"), + Arguments.of("TIME", "USA", "%h:%i:%s %p"), + Arguments.of("TIME", "JIS", "%H:%i:%s"), + Arguments.of("TIME", "ISO", "%H:%i:%s"), + Arguments.of("TIME", "EUR", "%H.%i.%s"), + Arguments.of("TIME", "INTERNAL", "%H%i%s"), Arguments.of("TIMESTAMP", "USA", "%Y-%m-%d %H.%i.%s"), - Arguments.of("TIME", "USA", "%h:%i:%s %p") + Arguments.of("TIMESTAMP", "JIS", "%Y-%m-%d %H:%i:%s"), + Arguments.of("TIMESTAMP", "ISO", "%Y-%m-%d %H:%i:%s"), + Arguments.of("TIMESTAMP", "EUR", "%Y-%m-%d %H.%i.%s"), + Arguments.of("TIMESTAMP", "INTERNAL", "%Y%m%d%H%i%s") ); } diff --git a/docs/user/dql/functions.rst b/docs/user/dql/functions.rst index e72175788d..b3877f3244 100644 --- a/docs/user/dql/functions.rst +++ b/docs/user/dql/functions.rst @@ -1773,7 +1773,7 @@ Usage: Returns a string value containing string format specifiers based on the i Argument type: TYPE, STRING TYPE must be one of the following tokens: [DATE, TIME, DATETIME, TIMESTAMP]. -STRING must be one of the following tokens: ["USA"] (" can be replaced by '). +STRING must be one of the following tokens: ["USA", "JIS", "ISO", "EUR", "INTERNAL"] (" can be replaced by '). Examples::