Skip to content

Commit

Permalink
Added some comments for clarification. Removed debug print
Browse files Browse the repository at this point in the history
  • Loading branch information
westonpace committed Feb 17, 2023
1 parent 777d136 commit cd40e50
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion python/pyarrow/table.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -5442,23 +5442,27 @@ list[tuple(str, str, FunctionOptions)]
"""
group_by_aggrs = []
for aggr in aggregations:
# Set opt to None if not specified
if len(aggr) == 2:
target, func = aggr
opt = None
else:
target, func, opt = aggr
# Ensure target is a list
if not isinstance(target, (list, tuple)):
target = [target]
# Ensure aggregate function is hash_ if needed
if len(self.keys) > 0 and not func.startswith("hash_"):
func = "hash_" + func
if len(self.keys) == 0 and func.startswith("hash_"):
func = func[5:]
# Determine output field name
func_nohash = func if not func.startswith("hash_") else func[5:]
if len(target) == 0:
aggr_name = func_nohash
else:
aggr_name = "_".join(target) + "_" + func_nohash
print("aggr_name=" + aggr_name)
# Calculate target indices by resolving field names
target_indices = [
self._table.schema.get_field_index(f) for f in target]
group_by_aggrs.append((target_indices, func, opt, aggr_name))
Expand Down

0 comments on commit cd40e50

Please sign in to comment.