将 RFC3339 字符串插入 bigquery 时出错

Error inserting RFC3339 string into bigquery

我有以下 datetime 字符串 2020-03-30T16:26:37-04:00,当我尝试将其插入 bigquery 时(我将字符串对象作为 json 对象的一部分发送)我得到错误

Invalid datetime string "2020-03-30T16:26:37-04:00" > 'invalid'`。

根据这个post,我认为格式没问题,但我仍然遇到错误

总结我如何在 BigQuery 中插入

如您所见hereDATETIME类型不支持时区。
正确的语法是 YYYY-[M]M-[D]D[( |T)[H]H:[M]M:[S]S[.DDDDDD]] 其中:

YYYY: Four-digit year
[M]M: One or two digit month
[D]D: One or two digit day
( |T): A space or a 'T' separator
[H]H: One or two digit hour (valid values from 00 to 23)
[M]M: One or two digit minutes (valid values from 00 to 59)
[S]S: One or two digit seconds (valid values from 00 to 59)
[.DDDDDD]: Up to six fractional digits (microsecond precision)

如果您需要时区,请考虑使用 TIMESTAMP
对于 TIMESTAMP 语法是 YYYY-[M]M-[D]D[( |T)[H]H:[M]M:[S]S[.DDDDDD]][time zone] 其中:

YYYY: Four-digit year
[M]M: One or two digit month
[D]D: One or two digit day
( |T): A space or a T separator
[H]H: One or two digit hour (valid values from 00 to 23)
[M]M: One or two digit minutes (valid values from 00 to 59)
[S]S: One or two digit seconds (valid values from 00 to 59)
[.DDDDDD]: Up to six fractional digits (microsecond precision)
[time zone]: String representing the time zone. When a time zone is not explicitly specified, the default time zone, UTC, is used. See the time zones section for details.

请注意,将新值插入时间戳字段时,该值将转换为 UTC。

希望对你有帮助