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:
Eugene Tolbakov
2023-06-12 10:21:49 +01:00
committed by GitHub
parent 1b2381502e
commit 51a4d660b7
3 changed files with 260 additions and 16 deletions

View File

@@ -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

View File

@@ -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;