我有以下查询:
C1 | C2| C3| C4
===|===|===|====
A | 1 | x | test
===|===|===|====
A | 2 | y | test
===|===|===|====
B | 1 | x | test
===|===|===|====
B | 1 | y | test
===|===|===|====
B | 1 | z | test
我希望将其转换为:
C1 | C2| C3| C4
===|===|===|====
B | 1 | x | test
===|===|===|====
B | 1 | y | test
===|===|===|====
B | 1 | z | test
因此,如果对于C1的唯一值,如果C2中存在多个值,则应该滤除C1 + C2的这种组合。
我尝试过的是:
| inputlookup LUT.csv
| fillnull value="NULL"
| stats list(*) as * dc("C2") as count by "C1"
| where count=1
但是结果是:
C1 | C2 | C3 | C4
===|=======|=======|==============
B | 1,1,1 | x,y,z | test,test,test
我不希望用逗号分隔值。我想要另一行。
这里是无处不在的例子。它使用streamstats
和stats
来计算C1 / C2对的变化数量。然后用一对C1 / C2对过滤掉任何东西。最后,mvexpand
将多值C3字段分成不同的事件。
| makeresults | eval _raw="C1 C2 C3 C4
A 1 x test
A 2 y test
B 1 x test
B 1 y test
B 1 z test" | multikv
`comment("Everything above is just test data")`
| streamstats reset_on_change=true count by C1,C2
| stats values(*) as * max(count) as max by C1
| where max > 1
| mvexpand C3
| table C1 C2 C3