You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用KQL移除嵌套数组内属性包中的指定键

解决方案

你需要用mv-apply遍历属性包数组的每个元素,逐个移除指定键后再重新组合数组。正确的KQL语句如下:

Resources
| mv-apply info = Properties.AdditionalInformation on (
    // 对数组中的每个属性包移除指定键
    extend cleaned_info = bag_remove_keys(info, dynamic(['KeyToRemove']))
    // 将处理后的元素重新组合为数组
    | summarize cleaned_additional_info = make_list(cleaned_info)
)
// 将处理后的数组合并回原Properties属性包,生成新的属性列
| extend cleaned_properties = bag_merge(Properties, dynamic({'AdditionalInformation': cleaned_additional_info}))
// 若要直接替换原Properties列,可添加以下两行
// | project-away Properties
// | rename cleaned_properties to Properties

关键说明:

  • mv-apply是KQL中处理数组元素遍历的核心运算符,它会把数组拆分成单个元素处理,之后再聚合回数组
  • 你之前的代码存在两个问题:
    1. 错误使用嵌套的|,KQL的每个管道运算符必须独立成行,不能嵌套在extend内部
    2. bag_remove_keys仅能处理单个属性包,无法直接作用于数组,必须遍历数组元素逐个操作

内容的提问来源于stack exchange,提问作者Labrockstar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 01:13:12