I created a table in BigQuery and in one of the columns I specified its mode as a REPEATED
(array) TIMESTAMP
column, that is column4
.
CREATE OR REPLACE TABLE
`project.dataset.table` ( column1 string,
column2 TIMESTAMP,
column3 ARRAY<int64>,
column4 ARRAY<TIMESTAMP>)
When I insert data into that table, the column4
converts the CURRENT_TIMESTAMP()
into the following format.
INSERT INTO
`project.dataset.table` (column1,
column2,
column3,
column4)
VALUES
("rowtest1", CURRENT_TIMESTAMP(), [5], [CURRENT_TIMESTAMP()])
In the same query I stated the CURRENT_TIMESTAMP()
to Column2
and Column4
, but for Column4
it changed the format of CURRENT_TIMESTAMP()
to 1660318705383274
instead 2022-08-12 15:38:25.383274 UTC
.
I want to keep the format as in the Column2 2022-08-12 15:38:25.383274 UTC
for both columns, is it possible?
I want to keep the column4
as REPEATED
because I will use it as an updated_at
field, to avoid redundancy in the table.
BigQuery UI seems to just display a timestamp value in an array as a format of unix timestamp. But internally, it still has a timestamp format in it.
See the query result as a JSON format.
SELECT [CURRENT_TIMESTAMP] ts;
And when you UNNEST an ARRAY<TIMESTAMP> , you can see it as a normal timestamp format like below.
SELECT ts FROM UNNEST([CURRENT_TIMESTAMP]) ts;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.