зеркало из https://github.com/Azure/pykusto.git
make_set_if function
This commit is contained in:
Родитель
d9d2a192eb
Коммит
b57f598105
|
@ -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)",
|
||||
|
|
Загрузка…
Ссылка в новой задаче