зеркало из https://github.com/Azure/pykusto.git
Merge pull request #18 from Azure/pykusto-15-fix-strcat
Issue #15 - fix strcat
This commit is contained in:
Коммит
d8737ac6a4
|
@ -570,10 +570,11 @@ def startofyear(expr: DatetimeType, offset: NumberType = None) -> DatetimeExpres
|
|||
|
||||
|
||||
def strcat(expr1: StringType, expr2: StringType, *exprs: StringType) -> StringExpression:
|
||||
res = 'strcat({}, {}, {})'.format(_subexpr_to_kql(expr1),
|
||||
_subexpr_to_kql(expr2),
|
||||
', '.join([_subexpr_to_kql(expr) for expr in exprs]))
|
||||
return StringExpression(KQL(res))
|
||||
res = 'strcat({}, {}'.format(_subexpr_to_kql(expr1),
|
||||
_subexpr_to_kql(expr2))
|
||||
if len(exprs) > 0:
|
||||
res = res + ', ' + ', '.join([_subexpr_to_kql(expr) for expr in exprs])
|
||||
return StringExpression(KQL(res + ')'))
|
||||
|
||||
|
||||
def strcat_array(expr: ArrayType, delimiter: StringType) -> StringExpression:
|
||||
|
@ -581,13 +582,13 @@ def strcat_array(expr: ArrayType, delimiter: StringType) -> StringExpression:
|
|||
|
||||
|
||||
def strcat_delim(delimiter: StringType, expr1: StringType, expr2: StringType, *exprs: StringType) -> StringExpression:
|
||||
res = 'strcat_delim({}, {}, {}, {})'.format(
|
||||
res = 'strcat_delim({}, {}, {}'.format(
|
||||
_subexpr_to_kql(delimiter),
|
||||
_subexpr_to_kql(expr1),
|
||||
_subexpr_to_kql(expr2),
|
||||
', '.join([_subexpr_to_kql(expr) for expr in exprs])
|
||||
)
|
||||
return StringExpression(KQL(res))
|
||||
_subexpr_to_kql(expr2))
|
||||
if len(exprs) > 0:
|
||||
res = res + ', ' + ', '.join([_subexpr_to_kql(expr) for expr in exprs])
|
||||
return StringExpression(KQL(res + ')'))
|
||||
|
||||
|
||||
def strcmp(expr1: StringType, expr2: StringType) -> NumberExpression:
|
||||
|
|
|
@ -321,12 +321,20 @@ class TestFunction(TestBase):
|
|||
" | extend (strcat(\"hello\", \",\", foo, \"!\"))",
|
||||
Query().extend(f.strcat("hello", ',', col.foo, '!')).render()
|
||||
)
|
||||
self.assertEqual(
|
||||
" | extend (strcat(foo, \"!\"))",
|
||||
Query().extend(f.strcat(col.foo, '!')).render()
|
||||
)
|
||||
|
||||
def test_strcat_delim(self):
|
||||
self.assertEqual(
|
||||
" | extend (strcat_delim(\"-\", \"hello\", \",\", foo, \"!\"))",
|
||||
Query().extend(f.strcat_delim('-', "hello", ',', col.foo, '!')).render()
|
||||
)
|
||||
self.assertEqual(
|
||||
" | extend (strcat_delim(\"-\", \",\", foo))",
|
||||
Query().extend(f.strcat_delim('-', ',', col.foo)).render()
|
||||
)
|
||||
|
||||
def test_strcat_array(self):
|
||||
self.assertEqual(
|
||||
|
|
Загрузка…
Ссылка в новой задаче