Avro 日期和时间与 BigQuery 的兼容性? [英] Compatibility of Avro dates and times with BigQuery?

查看:25
本文介绍了Avro 日期和时间与 BigQuery 的兼容性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

BigQuery 通常在加载 Avro 数据方面做得很好,但是bq load"在时间戳和其他使用 Avro logicalType 属性的日期/时间字段方面遇到了很多麻烦.

BigQuery generally does a good job of loading Avro data, but "bq load" is having a lot of trouble with timestamps and other date/time fields that use the Avro logicalType attribute.

  1. 当 BigQuery TIMESTAMP 将它们解释为微秒时间戳(减少 1000)时,我的 Avro 类型时间戳毫秒数据被破坏.
  2. 可以加载到 TIMESTAMP 的时间戳微整数在 BigQuery DATETIME 中变为无效.我在 https 上找不到对什么有效的解释://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
  3. ISO8601 格式的字符串无法加载到 TIMESTAMP 或 DATETIME(类型不兼容错误),但我认为如果我加载纯 JSON,BigQuery 会支持这一点.
  4. Avro日期"类型无法加载到 DATE(也是不兼容的类型).

我想我可以通过始终将数据加载到临时字段并使用查询进行 CAST 或将它们转换为其他字段来解决这些问题,但这不能很好地扩展或支持模式演变或流.在 Avro 中使用定义明确的模式生成数据应该可以避免为不同的消费者再次转换数据的额外步骤.

I guess I could workaround these problems by always loading the data into temporary fields and using queries to CAST or transform them to additional fields, but that doesn't scale or support schema evolution or stream nicely. Producing data in Avro with well-defined schemas is supposed to avoid that extra step of transforming data again for different consumers.

BigQuery 真的与 Avro 日期和时间不兼容吗?(或者我在做什么蠢事)

Is BigQuery really this incompatible with Avro dates and times? (or am I doing something dumb)

还是bq load"是这里的问题?有没有更好的方法来加载 Avro 数据?

Or is "bq load" the problem here? Is there a better way to load Avro data?

推荐答案

Avro 逻辑类型的本机理解现已公开提供给所有 BigQuery 用户.有关更多详细信息,请参阅此处的文档页面:https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-avro#logical_types

Native understanding for Avro Logical Types is now available publicly for all BigQuery users. Please refer to the documentation page here for more details: https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-avro#logical_types

这篇关于Avro 日期和时间与 BigQuery 的兼容性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆