gpt4 book ai didi

python - 谷歌bigquery中的时间戳格式丢失

转载 作者:太空狗 更新时间:2023-10-30 01:28:56 28 4
gpt4 key购买 nike

根据 another question ,我一直在这样做 (python) 以将我的时间戳插入 bigquery(它们来自 nr-of-miliseconds 格式的 node-js 应用程序):

e["createdOn"] = e["createdOn"] / 1000.0

但他们最终是这样的:

SELECT updatedOn,TIMESTAMP_TO_USEC(updatedOn) FROM [table.sessions] WHERE session = xxxxxxx
Row updatedOn f0_
1 2014-08-18 11:55:49 UTC 1408362949426000
2 2014-08-18 11:55:49 UTC 1408362949426000

我一直在打印调试信息,这是它们在用 insertAll 插入之前的最后一个形式:

{u'session': 100000000000080736, u'user': 1000000000075756, u'updatedOn': 1409052076.223}

最佳答案

我认为您混淆了 USEC(微秒)和 MSEC(毫秒)。您提供以毫秒为单位的时间戳,但随后转换为微秒,最后三位数字将为 0,因为这比您提供的精度更高。

如果您改为使用 TIMESTAMP_TO_MSEC 函数,它应该可以达到您的预期。

关于python - 谷歌bigquery中的时间戳格式丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25504922/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com