bigQuery not supporting milliseconds timestamps

后端 未结 1 461
醉酒成梦
醉酒成梦 2020-12-10 19:22

I have a value in my csv file for timetamp as \'1522865628160\'. When I load the data in bigQuery where this field type is timestamp, it saves the timestamp as \'15228656281

相关标签:
1条回答
  • 2020-12-10 19:53

    I think the issue here is that you tried to load your UNIX timestamp data into a timestamp column in BigQuery. A BigQuery timestamp column is not the same thing as a UNIX timestamp. The latter is just a numerical value representing the number of seconds since the start of the UNIX epoch in 1970.

    So the fix here would be to load your data into an INT64 (or INTEGER if you are using legacy) column. From there, you may convert your UNIX timestamp to a bona fide date or timestamp.

    There is a MSEC_TO_TIMESTAMP() function which can convert an integer number of milliseconds since the UNIX epoch to a bona fide timestamp, e.g.

    SELECT MSEC_TO_TIMESTAMP(1522865628160)
    
    2018-04-04 11:13:48 UTC
    
    0 讨论(0)
提交回复
热议问题