Skip to content

Commit

Permalink
feat(sql): support limited str.cat
Browse files Browse the repository at this point in the history
  • Loading branch information
machow committed Sep 19, 2023
1 parent 4f69352 commit 0c4d103
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions siuba/sql/dialects/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ def sql_func_capitalize(_, col):
rest = fn.right(col, fn.length(col) - 1)
return sql.functions.concat(first_char, rest)

def sql_str_cat(_, col, others=None, sep=None, na_rep=None, join=None):
if sep is not None:
raise NotImplementedError("sep argument not supported for sql cat")

if na_rep is not None:
raise NotImplementedError("na_rep argument not supported for sql cat")

if join is not None:
raise NotImplementedError("join argument not supported for sql cat")

if isinstance(others, (list, tuple)):
raise NotImplementedError("others argument must be a single column for sql cat")

return sql.functions.concat(col, others)

# Numpy ufuncs ----------------------------------------------------------------
# symbolic objects have a generic dispatch for when _.__array_ufunc__ is called,
Expand Down Expand Up @@ -252,6 +266,7 @@ def req_bool(f):
**{
# TODO: check generality of trim functions, since MYSQL overrides
"str.capitalize" : sql_func_capitalize,
"str.cat" : sql_str_cat,
#"str.center" :,
#"str.contains" :,
#"str.count" :,
Expand Down

0 comments on commit 0c4d103

Please sign in to comment.