Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions python/pyarrow/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ def _make_global_functions():
for cpp_name in reg.list_functions():
name = rewrites.get(cpp_name, cpp_name)
func = reg.get_function(cpp_name)
if func.kind == "hash_aggregate":
# Hash aggregate functions are not callable,
# so let's not expose them at module level.
continue
assert name not in g, name
g[cpp_name] = g[name] = _wrap_function(name, func)

Expand Down
14 changes: 13 additions & 1 deletion python/pyarrow/tests/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ def test_exported_functions():
func(*args)


def test_hash_aggregate_not_exported():
# Ensure we are not leaking hash aggregate functions
# which are not callable by themselves.
for func in exported_functions:
arrow_f = pc.get_function(func.__arrow_compute_function__["name"])
assert arrow_f.kind != "hash_aggregate"


def test_exported_option_classes():
classes = exported_option_classes
assert len(classes) >= 10
Expand Down Expand Up @@ -241,7 +249,11 @@ def test_pickle_functions():
def test_pickle_global_functions():
# Pickle global wrappers (manual or automatic) of registered functions
for name in pc.list_functions():
func = getattr(pc, name)
try:
func = getattr(pc, name)
except AttributeError:
# hash_aggregate functions are not exported as callables.
continue
reconstructed = pickle.loads(pickle.dumps(func))
assert reconstructed is func

Expand Down