Skip to content

Fix repr(Table) for group-by expressions#106

Open
windiana42 wants to merge 2 commits intomainfrom
fix-repr-group-by
Open

Fix repr(Table) for group-by expressions#106
windiana42 wants to merge 2 commits intomainfrom
fix-repr-group-by

Conversation

@windiana42
Copy link
Copy Markdown
Member

Summary

  • Fixes repr(pdt.Table) crashing with TypeError when the table has a group_by applied.
  • The issue was in get_head_tail(): calling summarize(num_rows=pdt.count()) on a grouped table produces the group-by columns plus num_rows, then export(pdt.Scalar) fails because it expects exactly one column.
  • The fix ungroups the table at the start of get_head_tail before summarizing and exporting.

Closes #96

Reproducer

import pydiverse.transform as pdt
from pydiverse.transform import C

tbl = pdt.Table({"a": [1, 2, 3], "b": [4, 5, 6], "c": [7, 8, 9]})
grouped = tbl >> pdt.group_by(C.a, C.b)
repr(grouped)  # was: TypeError, now prints the table correctly

Test plan

  • Verified the error reproduces on main
  • Verified repr() works after the fix

🤖 Generated with Claude Code

Ungroup the table in get_head_tail before summarizing, so the row count
export doesn't fail with multiple columns from the group-by keys.

Closes #96

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@windiana42 windiana42 requested a review from a team as a code owner March 19, 2026 20:35
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix repr(pdt.Table) for group-by expression

1 participant