Files
greptimedb/tests/cases/standalone/common/select/last_value.sql
Ruihang Xia 16075ada67 feat: impl optimizer rule to handle last_value case (#4357)
* feat: impl optimizer rule to handle last_value case

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* rename file

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* update sqlness result

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* Update src/query/src/optimizer/scan_hint.rs

Co-authored-by: Jeremyhi <jiachun_feng@proton.me>

* split methods

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Co-authored-by: Jeremyhi <jiachun_feng@proton.me>
2024-07-12 14:36:23 +00:00

29 lines
605 B
SQL

create table t (
ts timestamp time index,
host string primary key,
not_pk string,
val double,
);
insert into t values
(0, 'a', '🌕', 1.0),
(1, 'b', '🌖', 2.0),
(2, 'a', '🌗', 3.0),
(3, 'c', '🌘', 4.0),
(4, 'a', '🌑', 5.0),
(5, 'b', '🌒', 6.0),
(6, 'a', '🌓', 7.0),
(7, 'c', '🌔', 8.0),
(8, 'd', '🌕', 9.0);
-- Wait for #4354
-- explain analyze
-- select
-- last_value(host order by ts),
-- last_value(not_pk order by ts),
-- last_value(val order by ts)
-- from t
-- group by host;
drop table t;