This commit is contained in:
Adi Lefkowitz 2021-11-04 11:01:50 +02:00
Родитель d9d2a192eb
Коммит b57f598105
2 изменённых файлов: 20 добавлений и 0 удалений

Просмотреть файл

@ -1252,6 +1252,16 @@ class Functions:
return _ArrayAggregationExpression(KQL(f'make_set({_to_kql(expr)}, {_to_kql(max_size)})'))
return _ArrayAggregationExpression(KQL(f'make_set({_to_kql(expr)})'))
@staticmethod
def make_set_if(expr: ExpressionType, predicate: BooleanType, max_size: NumberType = None) -> _ArrayAggregationExpression:
"""
https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/makesetif-aggfunction
"""
if max_size is not None:
return _ArrayAggregationExpression(KQL(f'make_set_if({_to_kql(expr)}, {_to_kql(predicate)},'
f' {_to_kql(max_size)})'))
return _ArrayAggregationExpression(KQL(f'make_set_if({_to_kql(expr)}, {_to_kql(predicate)})'))
@staticmethod
def take_any(expr: ExpressionType, *expr_n: ExpressionType) -> _AnyAggregationExpression:
"""

Просмотреть файл

@ -842,6 +842,16 @@ class TestFunction(TestBase):
Query().summarize(f.take_any_all()).render()
)
def test_make_set_if(self):
self.assertEqual(
" | summarize make_set_if(stringField, numField == 1)",
Query().summarize(f.make_set_if(t.stringField, t.numField == 1)).render()
)
self.assertEqual(
" | summarize make_set_if(stringField, numField == 1, numField)",
Query().summarize(f.make_set_if(t.stringField, t.numField == 1, t.numField)).render()
)
def test_max(self):
self.assertEqual(
" | summarize max(numField)",