From 316ce38b5b05d055df229ebb3e14117c286486f3 Mon Sep 17 00:00:00 2001 From: morrySnow Date: Tue, 29 Aug 2023 11:38:43 +0800 Subject: [PATCH] [fix](view) The parameter positions of timestamp diff function to sql are reversed --- .../org/apache/doris/analysis/FunctionCallExpr.java | 4 ++-- regression-test/data/view_p0/view_p0.out | 3 +++ regression-test/suites/view_p0/view_p0.groovy | 10 ++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java index 17112e1f03deaf..d361bf99b5f7ac 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java @@ -557,8 +557,8 @@ private String paramsToSql() { || fnName.getFunction().equalsIgnoreCase("hours_diff") || fnName.getFunction().equalsIgnoreCase("minutes_diff") || fnName.getFunction().equalsIgnoreCase("seconds_diff")) { - sb.append(children.get(1).toSql()).append(", "); - sb.append(children.get(0).toSql()).append(")"); + sb.append(children.get(0).toSql()).append(", "); + sb.append(children.get(1).toSql()).append(")"); return sb.toString(); } // used by nereids END diff --git a/regression-test/data/view_p0/view_p0.out b/regression-test/data/view_p0/view_p0.out index a90e1f9623c44c..ff952fdaa7b833 100644 --- a/regression-test/data/view_p0/view_p0.out +++ b/regression-test/data/view_p0/view_p0.out @@ -12,3 +12,6 @@ 1 2023-08-01 DORID_FIELD1 DORID_FIELD2 ["cat", "dog"] cat 1 2023-08-01 DORID_FIELD1 DORID_FIELD2 ["cat", "dog"] dog +-- !sql -- +960 + diff --git a/regression-test/suites/view_p0/view_p0.groovy b/regression-test/suites/view_p0/view_p0.groovy index a6f20d41024ac8..bb6a5ab5a631e0 100644 --- a/regression-test/suites/view_p0/view_p0.groovy +++ b/regression-test/suites/view_p0/view_p0.groovy @@ -112,5 +112,15 @@ suite("view_p0") { ) c; """ qt_sql "select * from test_element_at_view;" + + sql "drop view if exists test_element_at_view" + + sql "drop view if exists test_time_diff" + + sql "create view test_time_diff as select minutes_diff('2023-01-16 10:05:04', '2023-01-15 18:05:04')" + + qt_sql "select * from test_time_diff" + + sql "drop view if exists test_time_diff" }