Skip to content

perf: Use semi-join instead of unique for checking 1:N relationships#362

Open
Oliver Borchert (borchero) wants to merge 2 commits into
mainfrom
semi-join
Open

perf: Use semi-join instead of unique for checking 1:N relationships#362
Oliver Borchert (borchero) wants to merge 2 commits into
mainfrom
semi-join

Conversation

@borchero

@borchero Oliver Borchert (borchero) commented Jul 6, 2026

Copy link
Copy Markdown
Member

Motivation

The current implementation builds two separate hash tables for no good reason. On some example data, this improves runtime of the filter itself by ~2.5x. End-to-end on the updated benchmark, it yields a ~5-10% runtime speedup.

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a523310) to head (3574fd7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #362   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           56        56           
  Lines         3475      3475           
=========================================
  Hits          3475      3475           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes the require_relationship_one_to_at_least_one relationship helper by avoiding unnecessary unique() work on the RHS, using a semi-join to filter lhs rows based on key existence in rhs (improving runtime by reducing redundant hashing).

Changes:

  • Replace rhs.unique(on) + inner join with how="semi" joins to check key existence more efficiently.
  • Preserve the existing optional lhs.unique(..., keep="none") behavior when drop_duplicates=True.

Comment thread dataframely/functional.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants