2.1.6,last_value() 函数似乎不支持 UNBOUNDED preceding

Viewed 76

版本:apache-doris-2.1.6-bin-x64
sql:
with mock as (
select 1 as id,1 sort,null state
union all
select 1 as id,2 sort,0 state
union all
select 1 as id,3 sort,3 state
union all
select 1 as id,4 sort,null state
union all
select 1 as id,5 sort,2 state
union all
select 1 as id,6 sort,null state
)

select
*,
last_value(state,1) over(
partition by id
order by sort
rows between UNBOUNDED preceding and current row
) last_to_current
from mock
order by sort;
将UNBOUNDED换位大点的数字 结果符合预期
8cc01bbf73d802455dd5a371d73613b.png
0f1fd3356852d7f5ce04f4c2ded2636.png

1 Answers