Skip to content

Commit 702de5d

Browse files
committed
fix(clickhouse): fix position call
1 parent cb7f0a3 commit 702de5d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

ibis/backends/clickhouse/compiler/values.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def _string_find(op, **kw):
277277

278278
arg = translate_val(op.arg, **kw)
279279
substr = translate_val(op.substr, **kw)
280-
return f"position({substr} IN {arg}) - 1"
280+
return f"locate({arg}, {substr}) - 1"
281281

282282

283283
@translate_val.register(ops.RegexExtract)
@@ -747,7 +747,7 @@ def _scalar_param(op, params: Mapping[ops.Node, Any], **kw):
747747
def _string_contains(op, **kw):
748748
haystack = translate_val(op.haystack, **kw)
749749
needle = translate_val(op.needle, **kw)
750-
return f"position({needle} IN {haystack}) > 0"
750+
return f"locate({haystack}, {needle}) > 0"
751751

752752

753753
def contains(op_string: Literal["IN", "NOT IN"]) -> str:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
position('a' IN string_col) - 1
1+
locate(string_col, 'a') - 1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
position(string_col IN string_col) - 1
1+
locate(string_col, string_col) - 1

0 commit comments

Comments
 (0)