My table has a few invalid timestamps that I think are too precise (maybe beyond microseconds) for BigQuery.
When I tried updating the table with the following query using Standard SQL:
UPDATE mytable
SET event_time = TIMESTAMP(DATETIME(TIMESTAMP_MILLIS(CAST(SUBSTR(SAFE_CAST(UNIX_MILLIS(event_time) AS string),1,13) AS int64))))
WHERE DATE(logtime) BETWEEN "2018-03-21" AND "2018-03-23"
AND event_time IS NOT NULL
I get the invalid timestamp error:
Cannot return an invalid timestamp value of 1521738691071000064 microseconds relative to the Unix epoch. The range of valid timestamp values is [0001-01-1 00:00:00, 9999-12-31 23:59:59.999999]; error in writing field event_time
I think the problem is the SET event_time = part, but I don't know how to get around setting the values in the event_time column without referring to it.
Anyone have any ideas on how to resolve this?
timestamp, then BigQuery doesn't think the values are invalid. - Gordon Linoffevent_timefield, because simply querying its raw data returns the same invalid timestamp error. Data is only returned if I transform it using the timestamp transformation I used in myupdatequery. However, my desired results would look something like this:2018-03-23 21:06:46.116 UTC- dnaeyeSELECT TO_JSON_STRING(a) FROM your_table a LIMIT 1- Felipe HoffaInvalid timestamp value: 1521749062783000064- dnaeye