将嵌套记录从Java数据流写入BigQuery

时间:2021-09-30 13:47:22

I have some objects with nested fields that I want to write from my dataflow job into a BigQuery table. I understand how to create the table schema, but I don't see how to create a TableRow with nested fields.

我有一些嵌套字段的对象,我想从我的数据流作业写入BigQuery表。我理解如何创建表模式,但我没有看到如何创建具有嵌套字段的TableRow。

The TableRow object is just a list of TableCell objects, which appear to be String,Object key-value pairs. How can I build a nested object this way? Can the value of a TableCell be a TableRow?

TableRow对象只是TableCell对象的列表,它们看起来是String,Object键值对。如何以这种方式构建嵌套对象? TableCell的值可以是TableRow吗?

1 个解决方案

#1


3  

The link shared by @ElliotBrossard points towards a solution: https://sookocheff.com/post/bigquery/writing-repeated-bigquery-records/

@ElliotBrossard分享的链接指向一个解决方案:https://sookocheff.com/post/bigquery/writing-repeated-bigquery-records/

Just as a repeated field is represented using a List<TableRow>, a nested field is represented using a TableRow where some of the field values are themselves TableRow objects.

就像使用List 表示重复字段一样,使用TableRow表示嵌套字段,其中一些字段值本身就是TableRow对象。

#1


3  

The link shared by @ElliotBrossard points towards a solution: https://sookocheff.com/post/bigquery/writing-repeated-bigquery-records/

@ElliotBrossard分享的链接指向一个解决方案:https://sookocheff.com/post/bigquery/writing-repeated-bigquery-records/

Just as a repeated field is represented using a List<TableRow>, a nested field is represented using a TableRow where some of the field values are themselves TableRow objects.

就像使用List 表示重复字段一样,使用TableRow表示嵌套字段,其中一些字段值本身就是TableRow对象。