Files
greptimedb/tests/cases/standalone/common/range/interval.sql
Yingwen 2f2b4b306c feat!: implement interval type by multiple structs (#4772)
* define structs and methods

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

* feat: re-implement interval types in time crate

* feat: use new

* feat: interval value

* feat: query crate interval

* feat: pg and mysql interval

* chore: remove unused imports

* chore: remove commented codes

* feat: make flow compile but may not work

* feat: flow datetime

* test: fix some tests

* test: fix some flow tests(WIP)

* chore: some fix test&docs

* fix: change interval order

* chore: remove unused codes

* chore: fix cilppy

* chore: now signature change

* chore: remove todo

* feat: update error message

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
Co-authored-by: discord9 <discord9@163.com>
2024-10-14 03:09:03 +00:00

22 lines
733 B
SQL

CREATE TABLE host (
ts timestamp(3) time index,
host STRING PRIMARY KEY,
val BIGINT,
);
INSERT INTO TABLE host VALUES
("1970-01-01T01:00:00+00:00", 'host1', 0),
("1970-01-01T02:00:00+00:00", 'host1', 1),
("1971-01-02T03:00:00+00:00", 'host1', 2),
("1971-01-02T04:00:00+00:00", 'host1', 3),
("1970-01-01T01:00:00+00:00", 'host2', 4),
("1970-01-01T02:00:00+00:00", 'host2', 5),
("1971-01-02T03:00:00+00:00", 'host2', 6),
("1971-01-02T04:00:00+00:00", 'host2', 7);
SELECT ts, host, min(val) RANGE (INTERVAL '1 year') FROM host ALIGN (INTERVAL '1 year') ORDER BY host, ts;
SELECT ts, host, min(val) RANGE (INTERVAL '1' day) FROM host ALIGN (INTERVAL '1' day) ORDER BY host, ts;
DROP TABLE host;