需要有关分区过多的 KQL 的帮助
Need Help on KQL with Over Partitions
我是 KQL 的新手,需要您对以下查询的帮助和建议。
我有如下数据:
Date Identity totalIngressInGB
2021-10-10 x 10
2021-10-10 y 20
2021-10-10 z 30
2021-10-10 q 10
2021-10-11 x 11
2021-10-11 y 22
2021-10-11 z 33
2021-10-11 p 10
2021-10-11 q 5
我想打印如下:
正在尝试打印当天值(totalIngressInGB_c)和前一天值(totalIngressInGB_p) 再差.
在 diffInGB 列中只打印正值,因为我只需要增量值。
Date Identity totalIngressInGB_c totalIngressInGB_p diffInGB
2021-10-11 X 11 10 1
2021-10-11 y 22 20 2
2021-10-11 z 33 30 3
2021-10-11 p 10 0 10
下面是 Hive 中的代码 SQL 和来自我们实际数据库的查询结果,现在数据在 ADX 中,我需要在 KQL 中打印相同的数据。我尝试了很多方法都无法在 KQL 中达到如下所示的准确结果。
您可以使用prev()
函数:https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/prevfunction
table(Date:datetime, Identity :string, totalIngressInGB:long)
[
datetime(2021-10-10), 'x', 10,
datetime(2021-10-10), 'y', 20,
datetime(2021-10-10), 'z', 30,
datetime(2021-10-10), 'q', 10,
datetime(2021-10-11), 'x', 11,
datetime(2021-10-11), 'y', 22,
datetime(2021-10-11), 'z', 33,
datetime(2021-10-11), 'p', 10,
datetime(2021-10-11), 'q', 5,
]
| order by Identity asc, Date asc
| project Date, Identity, totalIngressInGB_c = totalIngressInGB,
totalIngressInGB_p = case(prev(Identity) == Identity, prev(totalIngressInGB),
isempty(prev(Identity)), 0,
long(null))
| extend diff = totalIngressInGB_c - totalIngressInGB_p
| where diff > 0
我是 KQL 的新手,需要您对以下查询的帮助和建议。
我有如下数据:
Date Identity totalIngressInGB
2021-10-10 x 10
2021-10-10 y 20
2021-10-10 z 30
2021-10-10 q 10
2021-10-11 x 11
2021-10-11 y 22
2021-10-11 z 33
2021-10-11 p 10
2021-10-11 q 5
我想打印如下:
正在尝试打印当天值(totalIngressInGB_c)和前一天值(totalIngressInGB_p) 再差.
在 diffInGB 列中只打印正值,因为我只需要增量值。
Date Identity totalIngressInGB_c totalIngressInGB_p diffInGB
2021-10-11 X 11 10 1
2021-10-11 y 22 20 2
2021-10-11 z 33 30 3
2021-10-11 p 10 0 10
下面是 Hive 中的代码 SQL 和来自我们实际数据库的查询结果,现在数据在 ADX 中,我需要在 KQL 中打印相同的数据。我尝试了很多方法都无法在 KQL 中达到如下所示的准确结果。
您可以使用prev()
函数:https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/prevfunction
table(Date:datetime, Identity :string, totalIngressInGB:long)
[
datetime(2021-10-10), 'x', 10,
datetime(2021-10-10), 'y', 20,
datetime(2021-10-10), 'z', 30,
datetime(2021-10-10), 'q', 10,
datetime(2021-10-11), 'x', 11,
datetime(2021-10-11), 'y', 22,
datetime(2021-10-11), 'z', 33,
datetime(2021-10-11), 'p', 10,
datetime(2021-10-11), 'q', 5,
]
| order by Identity asc, Date asc
| project Date, Identity, totalIngressInGB_c = totalIngressInGB,
totalIngressInGB_p = case(prev(Identity) == Identity, prev(totalIngressInGB),
isempty(prev(Identity)), 0,
long(null))
| extend diff = totalIngressInGB_c - totalIngressInGB_p
| where diff > 0