mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-18 14:00:39 +00:00
* feat: let TypeConversionRule aware query context timezone setting * chore: don't optimize explain command * feat: parse string into timestamp with timezone * fix: compile error * chore: check the scalar value type in predicate * chore: remove mut for engine context * chore: return none if the scalar value is utf8 in time range predicate * fix: some fixme * feat: let Date and DateTime parsing from string value be aware of timezone * chore: tweak * test: add datetime from_str test with timezone * feat: construct function context from query context * test: add timezone test for to_unixtime and date_format function * fix: typo * chore: apply suggestion * test: adds string with timezone * chore: apply CR suggestion Co-authored-by: Lei, HUANG <6406592+v0y4g3r@users.noreply.github.com> * chore: apply suggestion --------- Co-authored-by: Lei, HUANG <6406592+v0y4g3r@users.noreply.github.com>
71 lines
1.5 KiB
SQL
71 lines
1.5 KiB
SQL
--- tests for timezone ---
|
|
SHOW VARIABLES time_zone;
|
|
|
|
SHOW VARIABLES system_time_zone;
|
|
|
|
CREATE TABLE test(d double, ts timestamp_ms time index);
|
|
|
|
INSERT INTO test values
|
|
(1, '2024-01-01 00:00:00'),
|
|
(2, '2024-01-02 08:00:00'),
|
|
(3, '2024-01-03 16:00:00'),
|
|
(4, '2024-01-04 00:00:00'),
|
|
(5, '2024-01-05 00:00:00+08:00');
|
|
|
|
SELECT * from test;
|
|
|
|
SELECT * from test where ts >= '2024-01-02 08:00:00';
|
|
|
|
SELECT * from test where ts <= '2024-01-03 16:00:00';
|
|
|
|
select date_format(ts, '%Y-%m-%d %H:%M:%S:%3f') from test;
|
|
|
|
select to_unixtime('2024-01-02 00:00:00');
|
|
|
|
select to_unixtime('2024-01-02T00:00:00+08:00');
|
|
|
|
--- UTC+8 ---
|
|
SET TIME_ZONE = '+8:00';
|
|
|
|
SHOW VARIABLES time_zone;
|
|
|
|
SHOW VARIABLES system_time_zone;
|
|
|
|
SELECT * from test;
|
|
|
|
SELECT * from test where ts >= '2024-01-02 08:00:00';
|
|
|
|
SELECT * from test where ts <= '2024-01-03 16:00:00';
|
|
|
|
select date_format(ts, '%Y-%m-%d %H:%M:%S:%3f') from test;
|
|
|
|
select to_unixtime('2024-01-02 00:00:00');
|
|
|
|
select to_unixtime('2024-01-02 00:00:00+08:00');
|
|
|
|
--- UTC-8 ---
|
|
SET TIME_ZONE = '-8:00';
|
|
|
|
SHOW VARIABLES time_zone;
|
|
|
|
SHOW VARIABLES system_time_zone;
|
|
|
|
SELECT * from test;
|
|
|
|
SELECT * from test where ts >= '2024-01-02 08:00:00';
|
|
|
|
SELECT * from test where ts <= '2024-01-03 16:00:00';
|
|
|
|
select date_format(ts, '%Y-%m-%d %H:%M:%S:%3f') from test;
|
|
|
|
select to_unixtime('2024-01-02 00:00:00');
|
|
|
|
select to_unixtime('2024-01-02 00:00:00+08:00');
|
|
|
|
drop table test;
|
|
|
|
-- revert timezone to UTC
|
|
SET TIME_ZONE = 'UTC';
|
|
|
|
SHOW VARIABLES time_zone;
|