Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cherry-pick](1.1-lts) cherry-pick lead function patch to 1.1-lts #12707

Merged
merged 1 commit into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 """

}