简体   繁体   中英

Google BigQuery removing leading 0s on fractional part of timestamp

BigQuery TIMESTAMP datatype has microsecond precision, 6 fractional seconds.

When I run the following query

SELECT CAST("2020-06-02 07:00:53.001000" AS TIMESTAMP) AS as_timestamp

I would expect 2020-06-02 07:00:53.001000 UTC What I get instead is... 2020-06-02 07:00:53.1000 UTC

As there is 2 leadings 0's, BigQuery omits them for some reason. Can anyone help me out at all to stop BigQuery omitting these leadings 0s? I'm trying to calculate some time differences between timestamps and it's throwing my calculations off.

Thanks

I strongly believe this is a UI bug, not a BigQuery Engine's

Below two proves for this

  • Prove 1
    Look at JSON tab to see actual value returned by BQ

在此处输入图像描述

  • Prove 2

I run same query in another BigQuery IDE ( I personally use Goliath BigQuery IDE) and you can see correct result

在此处输入图像描述

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM