Skip to content

perf: Faster local data comparison using idenitity #1738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2025
Merged
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: 2 additions & 2 deletions bigframes/core/local_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def from_arrow(cls, table: pa.Table) -> LocalTableMetadata:

@dataclasses.dataclass(frozen=True)
class ManagedArrowTable:
data: pa.Table = dataclasses.field(hash=False)
schema: schemata.ArraySchema = dataclasses.field(hash=False)
data: pa.Table = dataclasses.field(hash=False, compare=False)
schema: schemata.ArraySchema = dataclasses.field(hash=False, compare=False)
id: uuid.UUID = dataclasses.field(default_factory=uuid.uuid4)

@functools.cached_property
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/test_local_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,16 @@ def test_local_data_well_formed_round_trip_sliced():
result.reset_index(drop=True),
check_dtype=False,
)


def test_local_data_equal_self():
local_entry = local_data.ManagedArrowTable.from_pandas(pd_data)
assert local_entry == local_entry
assert hash(local_entry) == hash(local_entry)


def test_local_data_not_equal_other():
local_entry = local_data.ManagedArrowTable.from_pandas(pd_data)
local_entry2 = local_data.ManagedArrowTable.from_pandas(pd_data[::2])
assert local_entry != local_entry2
assert hash(local_entry) != hash(local_entry2)