Skip to content

Commit 842bfea

Browse files
committed
fix: make start truly optional in regexp_count
1 parent 8d7d9f2 commit 842bfea

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

python/datafusion/functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ def regexp_replace(
817817

818818

819819
def regexp_count(
820-
string: Expr, pattern: Expr, start: Expr, flags: Expr | None = None
820+
string: Expr, pattern: Expr, start: Expr | None = None, flags: Expr | None = None
821821
) -> Expr:
822822
"""Returns the number of matches in a string.
823823
@@ -826,7 +826,7 @@ def regexp_count(
826826
"""
827827
if flags is not None:
828828
flags = flags.expr
829-
start = start.expr if start is not None else Expr.expr
829+
start = start.expr if start is not None else start
830830
return Expr(f.regexp_count(string.expr, pattern.expr, start, flags))
831831

832832

python/tests/test_functions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,11 @@ def test_array_function_obj_tests(stmt, py_expr):
769769
pa.array(["H-o", "W-d", "!"], type=pa.string_view()),
770770
),
771771
(
772-
f.regexp_count(column("a"), literal("(ell|orl)"), literal(1)),
772+
f.regexp_count(column("a"), literal("(ell|orl)"), start=literal(1)),
773+
pa.array([1, 1, 0], type=pa.int64()),
774+
),
775+
(
776+
f.regexp_count(column("a"), literal("(ell|orl)")),
773777
pa.array([1, 1, 0], type=pa.int64()),
774778
),
775779
(

0 commit comments

Comments
 (0)