Skip to content

Commit

Permalink
[cherry-pick](1.1-lts) cherry-pick lead function patch to 1.1-lts (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel39 authored Sep 21, 2022
1 parent 1d2880d commit 25317a6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,10 @@ private void standardize(Analyzer analyzer) throws AnalysisException {
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="
Expand Down
10 changes: 10 additions & 0 deletions regression-test/data/correctness/test_lag_lead_window.out
Original file line number Diff line number Diff line change
Expand Up @@ -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

12 changes: 12 additions & 0 deletions regression-test/suites/correctness/test_lag_lead_window.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 """

}

0 comments on commit 25317a6

Please sign in to comment.