mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-06 21:32:58 +00:00
feat(to_unixtime): add timestamp types as arguments (#1632)
* feat(to_unixtime): add timestamp types as arguments * feat(to_unixtime): change the return type * feat(to_unixtime): address code review issues * feat(to_unixtime): fix fmt issue
This commit is contained in:
@@ -42,3 +42,64 @@ select TO_UNIXTIME('2023-03-01T06:35:02Z');
|
||||
| 1677652502 |
|
||||
+-------------------------------------------+
|
||||
|
||||
select TO_UNIXTIME(2);
|
||||
|
||||
+-----------------------+
|
||||
| to_unixtime(Int64(2)) |
|
||||
+-----------------------+
|
||||
| 2 |
|
||||
+-----------------------+
|
||||
|
||||
create table test_unixtime(a int, b timestamp time index);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DESC TABLE test_unixtime;
|
||||
|
||||
+-------+----------------------+------+---------+---------------+
|
||||
| Field | Type | Null | Default | Semantic Type |
|
||||
+-------+----------------------+------+---------+---------------+
|
||||
| a | Int32 | YES | | FIELD |
|
||||
| b | TimestampMillisecond | NO | | TIME INDEX |
|
||||
+-------+----------------------+------+---------+---------------+
|
||||
|
||||
insert into test_unixtime values(27, 27);
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
select * from test_unixtime;
|
||||
|
||||
+----+-------------------------+
|
||||
| a | b |
|
||||
+----+-------------------------+
|
||||
| 27 | 1970-01-01T00:00:00.027 |
|
||||
+----+-------------------------+
|
||||
|
||||
select a from test_unixtime;
|
||||
|
||||
+----+
|
||||
| a |
|
||||
+----+
|
||||
| 27 |
|
||||
+----+
|
||||
|
||||
select b from test_unixtime;
|
||||
|
||||
+-------------------------+
|
||||
| b |
|
||||
+-------------------------+
|
||||
| 1970-01-01T00:00:00.027 |
|
||||
+-------------------------+
|
||||
|
||||
select TO_UNIXTIME(b) from test_unixtime;
|
||||
|
||||
+------------------------------+
|
||||
| to_unixtime(test_unixtime.b) |
|
||||
+------------------------------+
|
||||
| 27 |
|
||||
+------------------------------+
|
||||
|
||||
DROP TABLE test_unixtime;
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
|
||||
@@ -11,3 +11,21 @@ select "A";
|
||||
select * where "a" = "A";
|
||||
|
||||
select TO_UNIXTIME('2023-03-01T06:35:02Z');
|
||||
|
||||
select TO_UNIXTIME(2);
|
||||
|
||||
create table test_unixtime(a int, b timestamp time index);
|
||||
|
||||
DESC TABLE test_unixtime;
|
||||
|
||||
insert into test_unixtime values(27, 27);
|
||||
|
||||
select * from test_unixtime;
|
||||
|
||||
select a from test_unixtime;
|
||||
|
||||
select b from test_unixtime;
|
||||
|
||||
select TO_UNIXTIME(b) from test_unixtime;
|
||||
|
||||
DROP TABLE test_unixtime;
|
||||
|
||||
Reference in New Issue
Block a user