Skip to content

Commit

Permalink
feat(datafusion): support substr without end
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztof-kwitt authored and cpcloud committed Feb 16, 2023
1 parent 5a74cb4 commit a19fd87
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 5 additions & 2 deletions ibis/backends/datafusion/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,11 @@ def capitalize(op):
def substring(op):
arg = translate(op.arg)
start = translate(ops.Add(left=op.start, right=1))
length = translate(op.length)
return df.functions.substr(arg, start, length)
if op_length := op.length:
length = translate(op_length)
return df.functions.substr(arg, start, length)
else:
return df.functions.substr(arg, start)


@translate.register(ops.Repeat)
Expand Down
4 changes: 0 additions & 4 deletions ibis/backends/tests/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,6 @@ def test_string_col_is_unicode(alltypes, df):
lambda t: t.date_string_col.str[2:],
id='substr-start-only',
marks=[
pytest.mark.notimpl(
["datafusion"],
raises=NotImplementedError,
),
pytest.mark.notimpl(
["pyspark"],
raises=com.OperationNotDefinedError,
Expand Down

0 comments on commit a19fd87

Please sign in to comment.