Merge pull request #153 from Azure/add_support_for_rand_and_has_any_experssions

Implementing review comments
This commit is contained in:
Ofri Kleinfeld 2021-05-11 16:57:58 +03:00 коммит произвёл GitHub
Родитель 21cdfc9eac a4a916f002
Коммит 8a5785b422
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 5 добавлений и 1 удалений

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

@ -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