Google bigquery Google BigQuery:UNNEST结构数组和unnested项作为结构

Google bigquery Google BigQuery:UNNEST结构数组和unnested项作为结构,google-bigquery,Google Bigquery,我有一个关于unesting带有结构的数组列的问题 我的源表架构如下所示 fields: - id: STRING::NULLABLE - response_choices: RECORD::REPEATED - response_choices.response_option_id: STRING::NULLABLE - response_choices.position:

我有一个关于
unest
ing带有结构的数组列的问题

我的源表架构如下所示

fields:
 - id:                                  STRING::NULLABLE
 - response_choices:                    RECORD::REPEATED
 - response_choices.response_option_id: STRING::NULLABLE
 - response_choices.position:           INT64::NULLABLE
 - response_choices.rendered_position:  INT64::NULLABLE
 - response_choices.responded_at:       DATETIME::NULLABLE

当我执行以下查询时

选择
*除了(回应和选择),
结构(
ro.response\u option\u id作为response\u option\u id,
ro.位置作为位置,
ro.渲染位置作为渲染位置,
ro.response\u datetime作为在
)作为你的选择
从我的回答表中,
UNNEST(响应_选项)作为ro
查询返回的数据既包括结构(如上所述),也将结构平面的列添加到结果中。因此,模式如下所示

字段:
-id:STRING::NULLABLE
-响应选项id:STRING::NULLABLE
-位置:INT64::NULLABLE
-渲染位置:INT64::NULLABLE
-响应时间:DATETIME::NULLABLE
-响应\u选项:记录::可空
-response\u choice.response\u option\u id:STRING::NULLABLE
-response_choice.position:INT64::NULLABLE
-response_choice.rendered_位置:INT64::NULLABLE
-response_choice.responsed_在:DATETIME::NULLABLE
但是,我会以一种只添加一个包含struct的字段的方式取消对数组的测试。原因是struct中的某些字段与表源中已有的字段冲突

我想买如下的东西

字段:
-id:STRING::NULLABLE
-响应\u选项:记录::可空
-response\u choice.response\u option\u id:STRING::NULLABLE
-response_choice.position:INT64::NULLABLE
-response_choice.rendered_位置:INT64::NULLABLE
-response_choice.responsed_在:DATETIME::NULLABLE

任何正确方向的建议或指点都将不胜感激!谢谢

下面是BigQuery标准SQL

#standardSQL
select t.* except(response_choices), 
  response_choice
from `project.dataset.my_responses_table` t,
unnest(response_choices) response_choice

我认为您在问题顶部提供的模式(源表)有问题-请仔细检查并更正(如果需要)。谢谢提示,我现在更新了schemamakes的含义-请参阅答案:o)