Skip to content

Commit

Permalink
fix(clickhouse): fix position call
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Jan 24, 2023
1 parent cb7f0a3 commit 702de5d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ibis/backends/clickhouse/compiler/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def _string_find(op, **kw):

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


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


def contains(op_string: Literal["IN", "NOT IN"]) -> str:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
position('a' IN string_col) - 1
locate(string_col, 'a') - 1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
position(string_col IN string_col) - 1
locate(string_col, string_col) - 1

0 comments on commit 702de5d

Please sign in to comment.