make_list()(聚合函数)

适用于:✅Azure 数据资源管理器Azure MonitorMicrosoft Sentinel

创建组中 expr 所有值的 dynamic 数组。

空值会被忽略,不会纳入计算中。

注意

此函数与 summarize 运算符结合使用。

弃用的别名:makelist()

语法

make_list(expr [, maxSize])

详细了解语法约定

参数

客户 类型​​ 必需 说明
expr dynamic ✔️ 用于聚合计算的表达式。
maxSize int 返回的最大元素数目。 默认值和最大值为 1048576。

注意

已弃用版本的默认 maxSize 限制为 128。

返回

返回组中 expr 所有值的 dynamic 数组。 如果未对 summarize 运算符的输入进行排序,那么生成的数组中的元素顺序将不确定。 如果对 summarize 运算符的输入进行了排序,则生成的数组中的元素顺序和输入一样。

提示

使用 array_sort_asc()array_sort_desc() 函数按某个键创建一个有序列表。

示例

一列

以下示例根据一个列生成一个列表:

let shapes = datatable (name: string, sideCount: int)
[
    "triangle", 3,
    "square", 4,
    "rectangle", 4,
    "pentagon", 5,
    "hexagon", 6,
    "heptagon", 7,
    "octagon", 8,
    "nonagon", 9,
    "decagon", 10
];
shapes
| summarize mylist = make_list(name)

输出

mylist
["triangle","square","rectangle","pentagon","hexagon","heptagon","octagon","nonagon","decagon"]

使用“by”子句

以下示例使用 by 子句运行查询:

let shapes = datatable (name: string, sideCount: int)
[
    "triangle", 3,
    "square", 4,
    "rectangle", 4,
    "pentagon", 5,
    "hexagon", 6,
    "heptagon", 7,
    "octagon", 8,
    "nonagon", 9,
    "decagon", 10
];
shapes
| summarize mylist = make_list(name) by isEvenSideCount = sideCount % 2 == 0

输出

isEvenSideCount mylist
false ["triangle","pentagon","heptagon","nonagon"]
["square","rectangle","hexagon","octagon","decagon"]

将动态对象打包

以下示例演示如何将动态对象打包到列中,然后再将其设置为列表。

let shapes = datatable (name: string, sideCount: int)
[
    "triangle", 3,
    "square", 4,
    "rectangle", 4,
    "pentagon", 5,
    "hexagon", 6,
    "heptagon", 7,
    "octagon", 8,
    "nonagon", 9,
    "decagon", 10
];
shapes
| extend d = bag_pack("name", name, "sideCount", sideCount)
| summarize mylist = make_list(d) by isEvenSideCount = sideCount % 2 == 0

输出

isEvenSideCount mylist
false [{"name":"triangle","sideCount":3},{"name":"pentagon","sideCount":5},{"name":"heptagon","sideCount":7},{"name":"nonagon","sideCount":9}]
[{"name":"square","sideCount":4},{"name":"rectangle","sideCount":4},{"name":"hexagon","sideCount":6},{"name":"octagon","sideCount":8},{"name":"decagon","sideCount":10}]

make_list_if 运算符与 make_list 相似,只是它也接受谓词。