Google BigQuery“bq”工具提取嵌套/重复记录,Java的API如何?

时间:2021-12-27 14:08:34

I've created a Google BigQuery table with five nested/repeated records, when I try queries ...bigquery.jobs().query(projectId, queryRequest).execute();... then ...queryResponse.getRows()..., BigQuery returns a flat json.
I've seen that the python bq --extract tool, is able to return pretty well the json. This json, effectively, is exactly the json that I've loaded. How is it possible with Java's API? Can someone help me, please? Thanks Onofrio

当我尝试查询时,我创建了一个包含五个嵌套/重复记录的Google BigQuery表... bigquery.jobs()。query(projectId,queryRequest).execute(); ... then ... queryResponse.getRows( )...,BigQuery返回一个扁平的json。我已经看到python bq --extract工具能够很好地返回json。这个json,实际上就是我加载的json。如何使用Java的API?有人能帮助我吗?谢谢Onofrio

1 个解决方案

#1


3  

BigQuery flattens the results of all queries. We've had a feature request for a while to provide the option to not flatten query results, and we may add support for this in the future.

BigQuery会使所有查询的结果变得扁平化。我们已经有一段时间的功能请求提供了不平整查询结果的选项,我们可能会在将来添加对此的支持。

If you want to read nested data from a table, however, you can use bigquery.tabledata().list(...), which will return nested/repeated json.

但是,如果要从表中读取嵌套数据,可以使用bigquery.tabledata()。list(...),它将返回嵌套/重复的json。

#1


3  

BigQuery flattens the results of all queries. We've had a feature request for a while to provide the option to not flatten query results, and we may add support for this in the future.

BigQuery会使所有查询的结果变得扁平化。我们已经有一段时间的功能请求提供了不平整查询结果的选项,我们可能会在将来添加对此的支持。

If you want to read nested data from a table, however, you can use bigquery.tabledata().list(...), which will return nested/repeated json.

但是,如果要从表中读取嵌套数据,可以使用bigquery.tabledata()。list(...),它将返回嵌套/重复的json。