This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-1.1-lts in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.1-lts by this push: new 25317a63e5 [cherry-pick](1.1-lts) cherry-pick `lead` function patch to 1.1-lts (#12707) 25317a63e5 is described below commit 25317a63e5105c8964626828eec667cffc93fa40 Author: Gabriel <gabrielleeb...@gmail.com> AuthorDate: Wed Sep 21 09:05:56 2022 +0800 [cherry-pick](1.1-lts) cherry-pick `lead` function patch to 1.1-lts (#12707) --- .../main/java/org/apache/doris/analysis/AnalyticExpr.java | 5 ++++- regression-test/data/correctness/test_lag_lead_window.out | 10 ++++++++++ .../suites/correctness/test_lag_lead_window.groovy | 12 ++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java index a8adc13940..180bcc76df 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java @@ -574,7 +574,10 @@ public class AnalyticExpr extends Expr { Type type = getFnCall().getChildren().get(2).getType(); try { - getFnCall().uncheckedCastChild(getFnCall().getChildren().get(0).getType(), 2); + if (!getFnCall().getChildren().get(0).getType() + .matchesType(getFnCall().getChildren().get(2).getType())) { + getFnCall().uncheckedCastChild(getFnCall().getChildren().get(0).getType(), 2); + } } catch (Exception e) { LOG.warn("" , e); throw new AnalysisException("Convert type error in offset fn(default value); old_type=" diff --git a/regression-test/data/correctness/test_lag_lead_window.out b/regression-test/data/correctness/test_lag_lead_window.out index ce24131517..87c6b2f8d1 100644 --- a/regression-test/data/correctness/test_lag_lead_window.out +++ b/regression-test/data/correctness/test_lag_lead_window.out @@ -9,3 +9,13 @@ /wyyt-image/2022/04/13/1434607674511761493.jpg /wyyt-image/2022/04/13/1434607674511761493.jpg /wyyt-image/2022/04/13/1434607674511761493.jpg +-- !select_default -- +c 2022-09-06T00:00:02 2022-09-06T00:00:01 +b 2022-09-06T00:00:01 2022-09-06T00:00 +a 2022-09-06T00:00 2022-09-06T00:00 + +-- !select_default -- +c 2022-09-06T00:00:02 2022-09-06T00:00:01 +b 2022-09-06T00:00:01 2022-09-06T00:00 +a 2022-09-06T00:00 + diff --git a/regression-test/suites/correctness/test_lag_lead_window.groovy b/regression-test/suites/correctness/test_lag_lead_window.groovy index 69ad1eeab4..ba7dded311 100644 --- a/regression-test/suites/correctness/test_lag_lead_window.groovy +++ b/regression-test/suites/correctness/test_lag_lead_window.groovy @@ -40,4 +40,16 @@ suite("test_lag_lead_window") { qt_select_default2 """ select min(t.cc) over(PARTITION by t.cc order by t.aa) , lead(t.cc,1,'') over (PARTITION by t.cc order by t.aa) as l1 from ${tableName} t; """ + sql """ DROP TABLE IF EXISTS test1 """ + sql """ CREATE TABLE IF NOT EXISTS test1 (id varchar(255), create_time datetime) + DISTRIBUTED BY HASH(id) PROPERTIES("replication_num" = "1"); """ + sql """ INSERT INTO test1 VALUES + ('a','2022-09-06 00:00:00'), + ('b','2022-09-06 00:00:01'), + ('c','2022-09-06 00:00:02') """ + qt_select_default """ select id, create_time, lead(create_time, 1, '2022-09-06 00:00:00') over + (order by create_time desc) as "prev_time" from test1; """ + qt_select_default """ select id, create_time, lead(create_time, 1, date_sub('2022-09-06 00:00:00', interval 7 day)) over (order by create_time desc) as "prev_time" from test1; """ + sql """ DROP TABLE IF EXISTS test1 """ + } \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org