зеркало из https://github.com/Azure/pykusto.git
Merge pull request #153 from Azure/add_support_for_rand_and_has_any_experssions
Implementing review comments
This commit is contained in:
Коммит
8a5785b422
|
@ -523,9 +523,10 @@ class _StringExpression(BaseExpression):
|
||||||
f'{self.as_subexpression()} {"!has_cs" if case_sensitive else "!has"} {_to_kql(exp, True)}'
|
f'{self.as_subexpression()} {"!has_cs" if case_sensitive else "!has"} {_to_kql(exp, True)}'
|
||||||
))
|
))
|
||||||
|
|
||||||
def has_any(self, other: ArrayType) -> '_BooleanExpression':
|
def has_any(self, other: Union[List, Tuple]) -> '_BooleanExpression':
|
||||||
"""
|
"""
|
||||||
https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/has-anyoperator
|
https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/has-anyoperator
|
||||||
|
Please notice that this implementation does not support tabular expression inputs currently
|
||||||
"""
|
"""
|
||||||
assert isinstance(other, (List, Tuple)), "Compared array must be a list of tabular, scalar, or literal expressions"
|
assert isinstance(other, (List, Tuple)), "Compared array must be a list of tabular, scalar, or literal expressions"
|
||||||
return _BooleanExpression(KQL(f'{self.kql} has_any ({", ".join(map(_to_kql, other))})'))
|
return _BooleanExpression(KQL(f'{self.kql} has_any ({", ".join(map(_to_kql, other))})'))
|
||||||
|
|
|
@ -648,6 +648,9 @@ class Functions:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def rand(n: NumberType = None):
|
def rand(n: NumberType = None):
|
||||||
|
"""
|
||||||
|
https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/randfunction
|
||||||
|
"""
|
||||||
return _NumberExpression(KQL("rand()") if n is None else f'rand({_to_kql(n)})')
|
return _NumberExpression(KQL("rand()") if n is None else f'rand({_to_kql(n)})')
|
||||||
|
|
||||||
# def range(self): return
|
# def range(self): return
|
||||||
|
|
Загрузка…
Ссылка в новой задаче