mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-14 17:23:09 +00:00
* feat: adds database() function to return current db * refactor: refactor meta src and client with new protos * feat: impl migrate_region and query_procedure_state for procedure service/client * fix: format * temp commit * feat: impl migrate_region SQL function * chore: clean code for review * fix: license header * fix: toml format * chore: update proto dependency * chore: apply suggestion Co-authored-by: Weny Xu <wenymedia@gmail.com> * chore: apply suggestion Co-authored-by: Weny Xu <wenymedia@gmail.com> * chore: apply suggestion Co-authored-by: JeremyHi <jiachun_feng@proton.me> * chore: apply suggestion Co-authored-by: fys <40801205+fengys1996@users.noreply.github.com> * chore: print key when parsing procedure id fails * chore: comment * chore: comment for MigrateRegionFunction --------- Co-authored-by: Weny Xu <wenymedia@gmail.com> Co-authored-by: JeremyHi <jiachun_feng@proton.me> Co-authored-by: fys <40801205+fengys1996@users.noreply.github.com>
304 lines
7.5 KiB
Plaintext
304 lines
7.5 KiB
Plaintext
--- tests for timezone ---
|
|
SHOW VARIABLES time_zone;
|
|
|
|
+-----------+
|
|
| TIME_ZONE |
|
|
+-----------+
|
|
| UTC |
|
|
+-----------+
|
|
|
|
SHOW VARIABLES system_time_zone;
|
|
|
|
+------------------+
|
|
| SYSTEM_TIME_ZONE |
|
|
+------------------+
|
|
| UTC |
|
|
+------------------+
|
|
|
|
select timezone();
|
|
|
|
+------------+
|
|
| timezone() |
|
|
+------------+
|
|
| UTC |
|
|
+------------+
|
|
|
|
CREATE TABLE test(d double, ts timestamp_ms time index);
|
|
|
|
Affected Rows: 0
|
|
|
|
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');
|
|
|
|
Affected Rows: 5
|
|
|
|
SELECT * from test;
|
|
|
|
+-----+---------------------+
|
|
| d | ts |
|
|
+-----+---------------------+
|
|
| 1.0 | 2024-01-01T00:00:00 |
|
|
| 2.0 | 2024-01-02T08:00:00 |
|
|
| 3.0 | 2024-01-03T16:00:00 |
|
|
| 4.0 | 2024-01-04T00:00:00 |
|
|
| 5.0 | 2024-01-04T16:00:00 |
|
|
+-----+---------------------+
|
|
|
|
SELECT * from test where ts >= '2024-01-02 08:00:00';
|
|
|
|
+-----+---------------------+
|
|
| d | ts |
|
|
+-----+---------------------+
|
|
| 2.0 | 2024-01-02T08:00:00 |
|
|
| 3.0 | 2024-01-03T16:00:00 |
|
|
| 4.0 | 2024-01-04T00:00:00 |
|
|
| 5.0 | 2024-01-04T16:00:00 |
|
|
+-----+---------------------+
|
|
|
|
SELECT * from test where ts <= '2024-01-03 16:00:00';
|
|
|
|
+-----+---------------------+
|
|
| d | ts |
|
|
+-----+---------------------+
|
|
| 1.0 | 2024-01-01T00:00:00 |
|
|
| 2.0 | 2024-01-02T08:00:00 |
|
|
| 3.0 | 2024-01-03T16:00:00 |
|
|
+-----+---------------------+
|
|
|
|
select date_format(ts, '%Y-%m-%d %H:%M:%S:%3f') from test;
|
|
|
|
+----------------------------------------------------+
|
|
| date_format(test.ts,Utf8("%Y-%m-%d %H:%M:%S:%3f")) |
|
|
+----------------------------------------------------+
|
|
| 2024-01-01 00:00:00:000 |
|
|
| 2024-01-02 08:00:00:000 |
|
|
| 2024-01-03 16:00:00:000 |
|
|
| 2024-01-04 00:00:00:000 |
|
|
| 2024-01-04 16:00:00:000 |
|
|
+----------------------------------------------------+
|
|
|
|
select to_unixtime('2024-01-02 00:00:00');
|
|
|
|
+------------------------------------------+
|
|
| to_unixtime(Utf8("2024-01-02 00:00:00")) |
|
|
+------------------------------------------+
|
|
| 1704153600 |
|
|
+------------------------------------------+
|
|
|
|
select to_unixtime('2024-01-02T00:00:00+08:00');
|
|
|
|
+------------------------------------------------+
|
|
| to_unixtime(Utf8("2024-01-02T00:00:00+08:00")) |
|
|
+------------------------------------------------+
|
|
| 1704124800 |
|
|
+------------------------------------------------+
|
|
|
|
--- UTC+8 ---
|
|
SET TIME_ZONE = '+8:00';
|
|
|
|
Affected Rows: 0
|
|
|
|
SHOW VARIABLES time_zone;
|
|
|
|
+-----------+
|
|
| TIME_ZONE |
|
|
+-----------+
|
|
| +08:00 |
|
|
+-----------+
|
|
|
|
SHOW VARIABLES system_time_zone;
|
|
|
|
+------------------+
|
|
| SYSTEM_TIME_ZONE |
|
|
+------------------+
|
|
| UTC |
|
|
+------------------+
|
|
|
|
select timezone();
|
|
|
|
+------------+
|
|
| timezone() |
|
|
+------------+
|
|
| +08:00 |
|
|
+------------+
|
|
|
|
SELECT * from test;
|
|
|
|
+-----+---------------------+
|
|
| d | ts |
|
|
+-----+---------------------+
|
|
| 1.0 | 2024-01-01T00:00:00 |
|
|
| 2.0 | 2024-01-02T08:00:00 |
|
|
| 3.0 | 2024-01-03T16:00:00 |
|
|
| 4.0 | 2024-01-04T00:00:00 |
|
|
| 5.0 | 2024-01-04T16:00:00 |
|
|
+-----+---------------------+
|
|
|
|
SELECT * from test where ts >= '2024-01-02 08:00:00';
|
|
|
|
+-----+---------------------+
|
|
| d | ts |
|
|
+-----+---------------------+
|
|
| 2.0 | 2024-01-02T08:00:00 |
|
|
| 3.0 | 2024-01-03T16:00:00 |
|
|
| 4.0 | 2024-01-04T00:00:00 |
|
|
| 5.0 | 2024-01-04T16:00:00 |
|
|
+-----+---------------------+
|
|
|
|
SELECT * from test where ts <= '2024-01-03 16:00:00';
|
|
|
|
+-----+---------------------+
|
|
| d | ts |
|
|
+-----+---------------------+
|
|
| 1.0 | 2024-01-01T00:00:00 |
|
|
| 2.0 | 2024-01-02T08:00:00 |
|
|
+-----+---------------------+
|
|
|
|
select date_format(ts, '%Y-%m-%d %H:%M:%S:%3f') from test;
|
|
|
|
+----------------------------------------------------+
|
|
| date_format(test.ts,Utf8("%Y-%m-%d %H:%M:%S:%3f")) |
|
|
+----------------------------------------------------+
|
|
| 2024-01-01 08:00:00:000 |
|
|
| 2024-01-02 16:00:00:000 |
|
|
| 2024-01-04 00:00:00:000 |
|
|
| 2024-01-04 08:00:00:000 |
|
|
| 2024-01-05 00:00:00:000 |
|
|
+----------------------------------------------------+
|
|
|
|
select to_unixtime('2024-01-02 00:00:00');
|
|
|
|
+------------------------------------------+
|
|
| to_unixtime(Utf8("2024-01-02 00:00:00")) |
|
|
+------------------------------------------+
|
|
| 1704124800 |
|
|
+------------------------------------------+
|
|
|
|
select to_unixtime('2024-01-02 00:00:00+08:00');
|
|
|
|
+------------------------------------------------+
|
|
| to_unixtime(Utf8("2024-01-02 00:00:00+08:00")) |
|
|
+------------------------------------------------+
|
|
| 1704124800 |
|
|
+------------------------------------------------+
|
|
|
|
--- UTC-8 ---
|
|
SET TIME_ZONE = '-8:00';
|
|
|
|
Affected Rows: 0
|
|
|
|
SHOW VARIABLES time_zone;
|
|
|
|
+-----------+
|
|
| TIME_ZONE |
|
|
+-----------+
|
|
| -08:00 |
|
|
+-----------+
|
|
|
|
SHOW VARIABLES system_time_zone;
|
|
|
|
+------------------+
|
|
| SYSTEM_TIME_ZONE |
|
|
+------------------+
|
|
| UTC |
|
|
+------------------+
|
|
|
|
select timezone();
|
|
|
|
+------------+
|
|
| timezone() |
|
|
+------------+
|
|
| -08:00 |
|
|
+------------+
|
|
|
|
SELECT * from test;
|
|
|
|
+-----+---------------------+
|
|
| d | ts |
|
|
+-----+---------------------+
|
|
| 1.0 | 2024-01-01T00:00:00 |
|
|
| 2.0 | 2024-01-02T08:00:00 |
|
|
| 3.0 | 2024-01-03T16:00:00 |
|
|
| 4.0 | 2024-01-04T00:00:00 |
|
|
| 5.0 | 2024-01-04T16:00:00 |
|
|
+-----+---------------------+
|
|
|
|
SELECT * from test where ts >= '2024-01-02 08:00:00';
|
|
|
|
+-----+---------------------+
|
|
| d | ts |
|
|
+-----+---------------------+
|
|
| 3.0 | 2024-01-03T16:00:00 |
|
|
| 4.0 | 2024-01-04T00:00:00 |
|
|
| 5.0 | 2024-01-04T16:00:00 |
|
|
+-----+---------------------+
|
|
|
|
SELECT * from test where ts <= '2024-01-03 16:00:00';
|
|
|
|
+-----+---------------------+
|
|
| d | ts |
|
|
+-----+---------------------+
|
|
| 1.0 | 2024-01-01T00:00:00 |
|
|
| 2.0 | 2024-01-02T08:00:00 |
|
|
| 3.0 | 2024-01-03T16:00:00 |
|
|
| 4.0 | 2024-01-04T00:00:00 |
|
|
+-----+---------------------+
|
|
|
|
select date_format(ts, '%Y-%m-%d %H:%M:%S:%3f') from test;
|
|
|
|
+----------------------------------------------------+
|
|
| date_format(test.ts,Utf8("%Y-%m-%d %H:%M:%S:%3f")) |
|
|
+----------------------------------------------------+
|
|
| 2023-12-31 16:00:00:000 |
|
|
| 2024-01-02 00:00:00:000 |
|
|
| 2024-01-03 08:00:00:000 |
|
|
| 2024-01-03 16:00:00:000 |
|
|
| 2024-01-04 08:00:00:000 |
|
|
+----------------------------------------------------+
|
|
|
|
select to_unixtime('2024-01-02 00:00:00');
|
|
|
|
+------------------------------------------+
|
|
| to_unixtime(Utf8("2024-01-02 00:00:00")) |
|
|
+------------------------------------------+
|
|
| 1704182400 |
|
|
+------------------------------------------+
|
|
|
|
select to_unixtime('2024-01-02 00:00:00+08:00');
|
|
|
|
+------------------------------------------------+
|
|
| to_unixtime(Utf8("2024-01-02 00:00:00+08:00")) |
|
|
+------------------------------------------------+
|
|
| 1704124800 |
|
|
+------------------------------------------------+
|
|
|
|
drop table test;
|
|
|
|
Affected Rows: 0
|
|
|
|
-- revert timezone to UTC
|
|
SET TIME_ZONE = 'UTC';
|
|
|
|
Affected Rows: 0
|
|
|
|
SHOW VARIABLES time_zone;
|
|
|
|
+-----------+
|
|
| TIME_ZONE |
|
|
+-----------+
|
|
| UTC |
|
|
+-----------+
|
|
|
|
select timezone();
|
|
|
|
+------------+
|
|
| timezone() |
|
|
+------------+
|
|
| UTC |
|
|
+------------+
|
|
|