Skip to content

Commit

Permalink
feat(clickhouse): implement ops.Capitalize
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztof-kwitt authored and cpcloud committed Feb 5, 2023
1 parent 104aeed commit 914c64c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ibis/backends/clickhouse/compiler/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,12 @@ def _string_ilike(op, **kw):
return f"lower({arg}) LIKE lower({pattern})"


@translate_val.register(ops.Capitalize)
def _string_capitalize(op, **kw):
arg = translate_val(op.arg, **kw)
return f"CONCAT(UPPER(SUBSTR({arg}, 1, 1)), SUBSTR({arg}, 2))"


@translate_val.register(ops.GroupConcat)
def _group_concat(op, **kw):
arg = translate_val(op.arg, **kw)
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/tests/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def test_string_col_is_unicode(alltypes, df):
lambda t: t.string_col.capitalize(),
lambda t: t.string_col.str.capitalize(),
id='capitalize',
marks=pytest.mark.notimpl(["clickhouse", "mssql"]),
marks=pytest.mark.notimpl(["mssql"]),
),
param(
lambda t: t.date_string_col.substr(2, 3),
Expand Down

0 comments on commit 914c64c

Please sign in to comment.