Skip to content

Commit

Permalink
fix(clickhouse): cast repeat times argument to UInt64
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Aug 29, 2022
1 parent 84f701c commit b643544
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ibis/backends/clickhouse/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,13 @@ def _nth_value(translator, expr):
return f"nth_value({arg}, ({nth}) + 1)"


def _repeat(translator, expr):
op = expr.op()
arg = translator.translate(op.arg)
times = translator.translate(op.times)
return f"repeat({arg}, CAST({times} AS UInt64))"


# TODO: clickhouse uses different string functions
# for ascii and utf-8 encodings,

Expand Down Expand Up @@ -789,7 +796,7 @@ def _nth_value(translator, expr):
ops.LStrip: _unary('trimLeft'),
ops.RStrip: _unary('trimRight'),
ops.Strip: _unary('trimBoth'),
ops.Repeat: _fixed_arity("repeat", 2),
ops.Repeat: _repeat,
ops.StringConcat: _string_concat,
ops.RegexSearch: _fixed_arity('match', 2),
ops.RegexExtract: _regex_extract,
Expand Down

0 comments on commit b643544

Please sign in to comment.