我正在尝试更新ga_sessions_表上的sourcePropertyDisplayName,它与另一个嵌套字段的值匹配。我在这里找到了这个答案:
Update nested field in BigQuery table
但这只有一个非常简单的WHERE TRUE;而我只想匹配指定的hits.eventInfo.eventCategory。
这是我到目前为止所做的:
UPDATE `dataset_name`.`ga_sessions_20170720`
SET hits =
ARRAY(
SELECT AS STRUCT * REPLACE(
(SELECT AS STRUCT sourcePropertyInfo.* REPLACE('updated text' AS
sourcePropertyDisplayName)) AS sourcePropertyInfo)
FROM UNNEST(hits)
)
WHERE ARRAY(
SELECT AS STRUCT eventInfo.eventCategory
FROM UNNEST(hits)
) LIKE '%SEARCH%'
但我目前收到以下错误:
Error: No matching signature for operator LIKE for argument types:
ARRAY<STRUCT<eventCategory STRING>>, STRING. Supported signatures: STRING
LIKE STRING; BYTES LIKE BYTES at [8:7]
如何使用WHERE子句中的另一个值更新一个嵌套字段?
答案 0 :(得分:0)
您的WHERE子句应如下所示
WHERE EXISTS (
SELECT 1 FROM UNNEST(hits) AS h
WHERE h.eventInfo.eventCategory LIKE '%SEARCH%'
)