diff --git a/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctions.java b/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctions.java index 483edd35d0d96..30b85a92e2c90 100644 --- a/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctions.java +++ b/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctions.java @@ -106,7 +106,8 @@ */ public class ScalarOperatorFunctions { public static final Set SUPPORT_JAVA_STYLE_DATETIME_FORMATTER = - ImmutableSet.builder().add("yyyy-MM-dd").add("yyyy-MM-dd HH:mm:ss").add("yyyyMMdd").build(); + ImmutableSet.builder().add("yyyy-MM-dd").add("yyyy-MM-dd HH:mm:ss").add("yyyyMMdd"). + add("yyyyMMdd HH:mm:ss").build(); private static final int CONSTANT_128 = 128; private static final BigInteger INT_128_OPENER = BigInteger.ONE.shiftLeft(CONSTANT_128 + 1); diff --git a/fe/fe-core/src/test/java/com/starrocks/connector/parser/trino/TrinoFunctionTransformTest.java b/fe/fe-core/src/test/java/com/starrocks/connector/parser/trino/TrinoFunctionTransformTest.java index c6e134eea03a3..2053ec7669fbd 100644 --- a/fe/fe-core/src/test/java/com/starrocks/connector/parser/trino/TrinoFunctionTransformTest.java +++ b/fe/fe-core/src/test/java/com/starrocks/connector/parser/trino/TrinoFunctionTransformTest.java @@ -171,13 +171,13 @@ public void testDateFnTransform() throws Exception { assertPlanContains(sql, "week_iso('2023-01-01 00:00:00')"); sql = "select format_datetime(TIMESTAMP '2023-06-25 11:10:20', 'yyyyMMdd HH:mm:ss')"; - assertPlanContains(sql, "jodatime_format('2023-06-25 11:10:20', 'yyyyMMdd HH:mm:ss')"); + assertPlanContains(sql, "20230625 11:10:20"); sql = "select format_datetime(date '2023-06-25', 'yyyyMMdd HH:mm:ss');"; - assertPlanContains(sql, "jodatime_format('2023-06-25', 'yyyyMMdd HH:mm:ss')"); + assertPlanContains(sql, "20230625 00:00:00"); sql = "select to_char(TIMESTAMP '2023-06-25 11:10:20', 'yyyyMMdd HH:mm:ss');"; - assertPlanContains(sql, "jodatime_format('2023-06-25 11:10:20', 'yyyyMMdd HH:mm:ss')"); + assertPlanContains(sql, "20230625 11:10:20"); sql = "select parse_datetime('2023-08-02 14:37:02', 'yyyy-MM-dd HH:mm:ss')"; assertPlanContains(sql, "str_to_jodatime('2023-08-02 14:37:02', 'yyyy-MM-dd HH:mm:ss')"); diff --git a/fe/fe-core/src/test/java/com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctionsTest.java b/fe/fe-core/src/test/java/com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctionsTest.java index 797a5a033a439..d24230b543b5b 100644 --- a/fe/fe-core/src/test/java/com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctionsTest.java +++ b/fe/fe-core/src/test/java/com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctionsTest.java @@ -306,7 +306,7 @@ public void dateFormat() { ScalarOperatorFunctions.dateFormat(testDate, ConstantOperator.createVarchar("yyyy")).getVarchar()); assertEquals("20010109", ScalarOperatorFunctions.dateFormat(testDate, ConstantOperator.createVarchar("yyyyMMdd")).getVarchar()); - assertEquals("yyyyMMdd HH:mm:ss", + assertEquals("20010109 13:04:05", ScalarOperatorFunctions.dateFormat(testDate, ConstantOperator.createVarchar("yyyyMMdd HH:mm:ss")) .getVarchar()); assertEquals("HH:mm:ss", @@ -1465,7 +1465,7 @@ public void testReplace() { @Test public void testJodatimeFormat() { assertEquals("20240806", ScalarOperatorFunctions.jodatimeFormat( - new ConstantOperator("2024-08-06", Type.DATE), + new ConstantOperator(LocalDateTime.parse("2024-08-06T12:30:45"), Type.DATE), new ConstantOperator("yyyyMMdd", Type.VARCHAR)).getVarchar()); }