gpt4 book ai didi

Azure 流处理使用数组将其更新插入到 DocumentDB

转载 作者:行者123 更新时间:2023-12-03 03:11:46 25 4
gpt4 key购买 nike

我正在使用 Azure 流分析将 Json 复制到 DocumentDB,并使用 upsert 用最新数据覆盖文档。这对于我的基础数据来说非常有用,但我希望能够附加列表数据,因为不幸的是我一次只能发送一个列表项。

在下面的示例中,文档在 id 上进行匹配,并且所有项目都已更新,但我希望“myList”数组随着每个文档(具有相同 id)中的“myList”数据而不断增长。这可能吗?是否有其他方法可以使用流分析来更新文档中的此列表?

如果可能的话,我宁愿避免使用滚动窗口,但这是一个可行的选择吗?

示例文档:

{
"id": "1234",
"otherData": "example",
"myList": [{"listitem": 1}]
}

{
"id": "1234",
"otherData": "example 2",
"myList": [{"listitem": 2}]
}

期望的输出:

{
"id": "1234",
"otherData": "example 2",
"myList": [{"listitem": 1}, {"listitem": 2}]
}

我当前的查询:

SELECT id, otherData, myList INTO [myoutput] FROM [myinput] 

最佳答案

当前阵列未合并,这是 ASA DocumentDB 输出的现有行为,在本 article 中也提到过。我怀疑使用翻滚窗口在这里会有帮助。

Note that changes in the values of array properties in your JSON document result in the entire array getting overwritten, i.e. the array is not merged.

您可以使用 GetArrayElements function 将数组 (myList) 形式的输入转换为字典。 。

您的查询可能类似于 --

选择 i.id 、 i.otherData 、 listItemFromArray
进入我的输出
从我的输入我
交叉应用 GetArrayElements(i.myList) AS listItemFromArray

干杯!

关于Azure 流处理使用数组将其更新插入到 DocumentDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36592728/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com