如何在不按名称指定每一列的情况下确定 Kusto table 中列子集的每个平均值
How do you determine each average for a subset of columns in a Kusto table without specify each column by name
我有一个 Kusto table,其中有 100 个 'duration' 列。我想计算每一列的平均持续时间。由于列数如此之大且不断变化,我想在不对列名称进行硬编码的情况下创建查询。
创建了一个打印出表示我的查询的硬编码版本的字符串的查询
SomeTable
| getschema
| where ColumnName endswith '_duration'
| summarize Columns = make_list(ColumnName)
// Make the query
| project strcat('SomeTable | summarize avg(', array_strcat(Columns, '), avg('), ') by Day = startofday(Event_ReceivedTime)')
我的目标是拥有一个不需要 table 中每一列的列表的查询。
我假设您想一次完成所有这些,而不是生成查询字符串然后执行该查询字符串?如果是这样,请查看 evaluate narrow()。如果您的数据集不是太大,那可能会完成工作。这是一个例子。
datatable(id:int, timestamp:datetime, x_duration:timespan, y_duration:timespan, z_duration:timespan)
[1, datetime(2019-07-19 17:51), time(01:00:00), time(02:00:00), time(03:00:00),
2, datetime(2019-07-19 17:52), time(01:10:00), time(02:10:00), time(03:10:00),
3, datetime(2019-07-19 17:53), time(01:10:10), time(02:10:10), time(03:10:10)]
| evaluate narrow()
| where Column endswith('_duration')
| extend Value = totimespan(Value)
| summarize avg(Value) by Column
Column avg_Value
x_duration 01:06:43.3333333
y_duration 02:06:43.3333333
z_duration 03:06:43.3333333
我有一个 Kusto table,其中有 100 个 'duration' 列。我想计算每一列的平均持续时间。由于列数如此之大且不断变化,我想在不对列名称进行硬编码的情况下创建查询。
创建了一个打印出表示我的查询的硬编码版本的字符串的查询
SomeTable
| getschema
| where ColumnName endswith '_duration'
| summarize Columns = make_list(ColumnName)
// Make the query
| project strcat('SomeTable | summarize avg(', array_strcat(Columns, '), avg('), ') by Day = startofday(Event_ReceivedTime)')
我的目标是拥有一个不需要 table 中每一列的列表的查询。
我假设您想一次完成所有这些,而不是生成查询字符串然后执行该查询字符串?如果是这样,请查看 evaluate narrow()。如果您的数据集不是太大,那可能会完成工作。这是一个例子。
datatable(id:int, timestamp:datetime, x_duration:timespan, y_duration:timespan, z_duration:timespan)
[1, datetime(2019-07-19 17:51), time(01:00:00), time(02:00:00), time(03:00:00),
2, datetime(2019-07-19 17:52), time(01:10:00), time(02:10:00), time(03:10:00),
3, datetime(2019-07-19 17:53), time(01:10:10), time(02:10:10), time(03:10:10)]
| evaluate narrow()
| where Column endswith('_duration')
| extend Value = totimespan(Value)
| summarize avg(Value) by Column
Column avg_Value
x_duration 01:06:43.3333333
y_duration 02:06:43.3333333
z_duration 03:06:43.3333333