想要自定义排序顺序?
Kusto Custom Sort Order?
如何在 Kusto 中执行自定义排序顺序?
示例查询:
//==================================================//
// Assign variables
//==================================================//
let varStart = ago(2d);
let varEnd = now();
let varStorageAccount = 'stgacctname';
//==================================================//
// Filter table
//==================================================//
StorageBlobLogs
| where TimeGenerated between (varStart .. varEnd)
and AccountName == varStorageAccount
| sort by OperationName
需要:
- 我想将各种
OperationNames
(GetBlob
、AppendFile
等)放入自定义订单中。
- 类似于:
| sort by OperationName['GetBlob'], OperationName['AppendFile'], OperationName asc
- 理想情况下,我想指定要排序的值,然后允许 Kusto 使用
asc
/desc
. 对剩余的值进行排序
这可能吗?
使用辅助列,如下所示:
datatable(OperationName:string, SomethingElse:string)
[
"AppendFile", "3",
"GetBlob", "1",
"AppendFile", "4",
"GetBlob", "2"
]
| extend OrderPriority =
case(OperationName == "GetBlob", 1,
OperationName == "AppendFile", 2,
3)
| order by OrderPriority asc, SomethingElse asc
| project-away OrderPriority
输出:
OperationName
SomethingElse
GetBlob
1
GetBlob
2
AppendFile
3
AppendFile
4
如何在 Kusto 中执行自定义排序顺序?
示例查询:
//==================================================//
// Assign variables
//==================================================//
let varStart = ago(2d);
let varEnd = now();
let varStorageAccount = 'stgacctname';
//==================================================//
// Filter table
//==================================================//
StorageBlobLogs
| where TimeGenerated between (varStart .. varEnd)
and AccountName == varStorageAccount
| sort by OperationName
需要:
- 我想将各种
OperationNames
(GetBlob
、AppendFile
等)放入自定义订单中。 - 类似于:
| sort by OperationName['GetBlob'], OperationName['AppendFile'], OperationName asc
- 理想情况下,我想指定要排序的值,然后允许 Kusto 使用
asc
/desc
. 对剩余的值进行排序
这可能吗?
使用辅助列,如下所示:
datatable(OperationName:string, SomethingElse:string)
[
"AppendFile", "3",
"GetBlob", "1",
"AppendFile", "4",
"GetBlob", "2"
]
| extend OrderPriority =
case(OperationName == "GetBlob", 1,
OperationName == "AppendFile", 2,
3)
| order by OrderPriority asc, SomethingElse asc
| project-away OrderPriority
输出:
OperationName | SomethingElse |
---|---|
GetBlob | 1 |
GetBlob | 2 |
AppendFile | 3 |
AppendFile | 4 |