按照在https://cloud.google.com/bigquery/sql-reference/dml-syntax中找到的示例,我们想出了一种方法来更新表的第 3 级(specifications.dimensions),如下所示:
UPDATE sd97dwo.DetailedInventory
SET specifications.dimensions =
STRUCT<depth FLOAT64, height FLOAT64, width FLOAT64>(1, 2, 3)
WHERE
product like '%washer%'
AND EXISTS(select 1 from unnest(comments) as c where c.comment like '%comment%')
我们现在要做的是更新表以将记录附加到相同的维度结构。但是,我们尝试的各种方法都没有成功。想看看有没有人有什么想法。我们得到的最接近的是下面,但是当然返回了 specification.dimensions 的所有记录(作为多个结果),所以我们得到错误“标量子查询产生了多个元素”
UPDATE sd97dwo.DetailedInventory
SET specifications.dimensions
= (SELECT specifications.dimensions
UNION ALL
SELECT STRUCT<depth FLOAT64, height FLOAT64, width FLOAT64>(4.0,5.0,6.0))
WHERE
product like '%washer%'
AND EXISTS(select 1 from unnest(comments) as c where c.comment like '%comment%')