有没有办法避免从 STRING 到 STRUCT 的数据类型转换用于将数据存储区导入 BigQuery?

发布于 2025-01-19 13:08:52 字数 421 浏览 3 评论 0 原文

我们每天都会自动将数据存储备份加载到 BigQuery 以进行进一步分析并覆盖该表。

当在 BigQuery 中导入至少一个包含长文本实体的数据存储种类时,该字段会自动转换为 STRUCT 而不是 STRING< /code> 字段与所有其他文本/字符串字段一样。然后,这会更改 BigQuery 表的架构,并使任何进一步的处理或分析变得非常困难,因为需要调整查询来解决这一问题。我们无法控制数据存储端的文本长度,因此我们需要找到一种方法至少稳定 BigQuery 端的架构。

关于如何优雅地处理这个问题有什么想法吗?

有什么方法可以避免这种转换,这样 BigQuery 表的架构就不会改变?

We are automatically loading Datastore Backups to BigQuery for further analysis overwriting the table every day.

When a Datastore Kind with at least one Entity with long text is imported in BigQuery, that field is automatically converted to a STRUCT<string STRING, text STRING, provided STRING> instead of a STRING field like all the other text/string fields. This then changes the schema of the BigQuery table and makes any further processing or analysis really hard as queries need to be adapted to account for this. We cannot control the length of text on the Datastore side, so we need to find a way to at least stabilize the schema on the BigQuery side.

Any idea on how to deal with this elegantly?

Any way this conversion can be avoided so the schema of the BigQuery table does not change?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝天白云 2025-01-26 13:08:52

在 BigQuery 中无法将架构设置为从数据存储区导出的加载作业。这意味着模式将始终从数据中推断出来。例如,如果您尝试通过 UI 加载它,您将看到一条消息:

Source file defines the schema

In this 链接 您可以了解 Datastore 和 BigQuery 之间类型转换的工作原理。

尝试使用视图作为最终表或创建计划查询以在加载表时读取表并将结果保存在具有正确架构的另一个表中。

Setting a schema to a Load Job from a Datastore export is not possible in BigQuery. It means that the schema will always be inferred from the data. If you try to load it through the UI for example, you will see a message saying

Source file defines the schema

In this link you can find how the type conversion works between Datastore and BigQuery.

Try to use a View as the final table or create a scheduled query to read your table when its loaded and save the results in another table with the right schema.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文