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 beb8952a888a9..3bb2cb023ae2c 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 ddb877ae908dc..a4aaa3492ee46 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 @@ -180,13 +180,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 98d4de3c72c26..a53d8f3628723 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 @@ -326,7 +326,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", @@ -1505,7 +1505,7 @@ public void testLowerUpper() { @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()); }