Skip to content

Commit e53d708

Browse files
committed
Add list_repeat
1 parent fe4a7ab commit e53d708

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

python/datafusion/functions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
"list_prepend",
165165
"list_push_back",
166166
"list_push_front",
167+
"list_repeat",
167168
"list_remove",
168169
"list_remove_all",
169170
"list_remove_n",
@@ -1384,6 +1385,14 @@ def array_repeat(element: Expr, count: Expr) -> Expr:
13841385
return Expr(f.array_repeat(element.expr, count.expr))
13851386

13861387

1388+
def list_repeat(element: Expr, count: Expr) -> Expr:
1389+
"""Returns an array containing ``element`` ``count`` times.
1390+
1391+
This is an alias for :py:func:`array_repeat`.
1392+
"""
1393+
return array_repeat(element, count)
1394+
1395+
13871396
def array_replace(array: Expr, from_val: Expr, to_val: Expr) -> Expr:
13881397
"""Replaces the first occurrence of ``from_val`` with ``to_val``."""
13891398
return Expr(f.array_replace(array.expr, from_val.expr, to_val.expr))

python/tests/test_functions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,10 @@ def py_flatten(arr):
445445
lambda col: f.array_repeat(col, literal(2)),
446446
lambda data: [[arr] * 2 for arr in data],
447447
],
448+
[
449+
lambda col: f.list_repeat(col, literal(2)),
450+
lambda data: [[arr] * 2 for arr in data],
451+
],
448452
[
449453
lambda col: f.array_replace(col, literal(3.0), literal(4.0)),
450454
lambda data: [py_arr_replace(arr, 3.0, 4.0, 1) for arr in data],

0 commit comments

Comments
 (0)