Skip to content

Commit 5bdb436

Browse files
committed
Refactor group_by expression handling in DataFrame to use expr_list_to_raw_expr_list for improved clarity and consistency
1 parent 50b4328 commit 5bdb436

1 file changed

Lines changed: 1 addition & 12 deletions

File tree

python/datafusion/dataframe.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -531,18 +531,7 @@ def aggregate(
531531
group_by_list = group_by if isinstance(group_by, list) else [group_by]
532532
aggs_list = aggs if isinstance(aggs, list) else [aggs]
533533

534-
group_by_exprs = []
535-
for e in group_by_list:
536-
if isinstance(e, str):
537-
group_by_exprs.append(Expr.column(e).expr)
538-
elif isinstance(e, Expr):
539-
group_by_exprs.append(e.expr)
540-
else:
541-
error = (
542-
"Expected Expr or column name, found:"
543-
f" {type(e).__name__}. Use col() or lit() to construct expressions"
544-
)
545-
raise TypeError(error)
534+
group_by_exprs = expr_list_to_raw_expr_list(group_by_list)
546535
aggs_exprs = []
547536
for agg in aggs_list:
548537
if not isinstance(agg, Expr):

0 commit comments

Comments
 (0)