【发布时间】:2020-10-27 00:59:45
【问题描述】:
我有一个 Google Big Query 数据集,其中的字段位于表中的数组内。我可以使用 SELECT 语句中的子查询访问数组中的值。例如:
(select custom_fields.value.value from tickets.custom_fields where custom_fields.value.id=35374507) AS Organization
问题是我需要通过将表 A 中的一个数组与表 B 中另一个数组中的值进行匹配来访问表 A 中的一个数组中的值。我首先尝试通过在 SELECT 语句的子查询中使用子查询来做到这一点如下:
tickets.id,
(select (select custom_field_options.value.name from ticket_fields.custom_field_options
where custom_field_options.value.value=(select custom_fields.value.value from
tickets.custom_fields where custom_fields.value.id=360014264753))
from zendesk.ticket_fields) AS Issue
from zendesk.tickets
where tickets.id=6869
但这给出了以下错误:“不支持引用其他表的相关子查询,除非它们可以去相关,例如通过将它们转换为有效的 JOIN。”
我现在正在尝试使用 FROM 子句中的子查询来创建两个临时表并将它们连接起来,如下所示:
SELECT
I.custom_field_options.value.name AS Issue_name,
C.custom_fields.value.value AS Issue_value
FROM
(select custom_field_options from zendesk.ticket_fields) As I
JOIN
(select custom_fields from zendesk.tickets) AS C
ON I.custom_field_options.value.value = C.custom_fields.value.value
WHERE C.custom_fields.value.id=360014264753
但这会产生以下错误:“无法访问类型为 ARRAY
【问题讨论】:
-
你检查过这个堆栈thread吗?
标签: sql google-bigquery zendesk-api