我正在尝试保存在BigQuery中连接两个表的查询视图。以下是这些表的简化模式。
在BigQuery UI中运行以下查询会返回我期望的结果:
SELECT *
FROM [dataset_name.table1] as t1
JOIN [dataset_name.table2] as t2
ON t1.primaryEmail = t2.user_email
然后,点击按钮保存视图会返回以下错误:
Failed to save view. Cannot create valid output schema for field organizations.description.
Try renaming organizations.description to t1.organizations.description in the outermost SELECT.
重新命名最外层选择中的字段似乎非常痛苦,因为我可能必须在同一个选择中指定我的两个表的所有字段(很多)。
我是否错过了有关观点的内容?
编辑1:我设法通过指定SELECT中的所有字段并仅为记录子字段添加t1.organizations.xxx AS t1.organizations.xxx
(基于错误的建议)来创建视图:
SELECT
t1.primaryEmail,
t1.suspended,
t1.name.familyName,
t1.name.fullName,
t1.name.givenName,
t1.organizations.name as t1.organizations.name,
t1.organizations.title as t1.organizations.title,
t1.organizations.primary as t1.organizations.primary,
t2.report_date
FROM [dataset_name.table1] t1 JOIN [dataset_name.table2] t2 ON t1.primaryEmail = t2.user_email
它会创建一个带有额外不需要的记录字段 t1 的视图:
答案 0 :(得分:0)
您还可以执行group by
以使每条记录都唯一,从而将其转换为视图。