按照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%')
我们现在要做的是,将表更新为APPEND记录到相同维度的结构。但是,我们尝试的各种方式并不成功。想知道是否有人有任何想法。我们得到的最接近的是下面的,但当然返回所有记录(作为多个结果)的specifications.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%')
答案 0 :(得分:3)
我们现在要做的是,将表更新为APPEND记录到相同维度的结构。
你的架构是什么? 如果您使用与DML文档中相同的模式,那么&#34;规范&#34;也不是&#34;尺寸&#34;是重复的领域。所以你无法附加它。但您可以直接更新它们,如:
UPDATE sd97dwo.DetailedInventory
SET specifications.dimensions.depth = 1,
specifications.dimensions.height = 2,
specifications.dimensions.width = 3
WHERE
product like '%washer%'
AND EXISTS(select 1 from unnest(comments) as c where c.comment like '%comment%')