зеркало из https://github.com/Azure/pykusto.git
add has_any expression
This commit is contained in:
Родитель
e7b63aba70
Коммит
c89748a976
|
@ -523,6 +523,13 @@ 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':
|
||||||
|
"""
|
||||||
|
https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/has-anyoperator
|
||||||
|
"""
|
||||||
|
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))})'))
|
||||||
|
|
||||||
|
|
||||||
@_plain_expression(_KustoType.DATETIME)
|
@_plain_expression(_KustoType.DATETIME)
|
||||||
class _DatetimeExpression(BaseExpression):
|
class _DatetimeExpression(BaseExpression):
|
||||||
|
|
|
@ -450,6 +450,16 @@ class TestExpressions(TestBase):
|
||||||
Query().where(t.stringField.has("test", case_sensitive=True)).render()
|
Query().where(t.stringField.has("test", case_sensitive=True)).render()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_has_any(self):
|
||||||
|
self.assertEqual(
|
||||||
|
' | where stringField has_any ("field", "string")',
|
||||||
|
Query().where(t.stringField.has_any(["field", "string"])).render()
|
||||||
|
)
|
||||||
|
self.assertRaises(
|
||||||
|
AssertionError("Compared array must be a list of tabular, scalar, or literal expressions"),
|
||||||
|
lambda: t.stringField.has_any(t.stringField2)
|
||||||
|
)
|
||||||
|
|
||||||
def test_column_generator(self):
|
def test_column_generator(self):
|
||||||
field1 = col.foo
|
field1 = col.foo
|
||||||
field2 = col['foo.bar']
|
field2 = col['foo.bar']
|
||||||
|
|
Загрузка…
Ссылка в новой задаче