Skip to content

fix(python): Issue PerformanceWarning in LazyFrame.__contains__ - #26734

Merged
nameexhaustion merged 6 commits into
pola-rs:mainfrom
toroleapinc:fix/issue-21917-lazyframe-contains-performance-warning
Mar 10, 2026
Merged

fix(python): Issue PerformanceWarning in LazyFrame.__contains__#26734
nameexhaustion merged 6 commits into
pola-rs:mainfrom
toroleapinc:fix/issue-21917-lazyframe-contains-performance-warning

Conversation

@toroleapinc

Copy link
Copy Markdown
Contributor

Summary

Add PerformanceWarning to LazyFrame.__contains__ to match the behavior of other LazyFrame properties (schema, columns, dtypes, width) that require resolving the schema.

Changes

  • Added issue_warning() call with PerformanceWarning category in LazyFrame.__contains__
  • Added test case for the new warning in test_lazyframe.py

Rationale

As noted in #21917, after #16964 all other methods on LazyFrame that might unexpectedly cause the schema to be resolved emit PerformanceWarning, except for __contains__. This was an oversight since 'col' in lf is functionally identical to 'col' in lf.columns which does emit the warning.

Fixes #21917

Add PerformanceWarning to LazyFrame.__contains__ to match the behavior
of other LazyFrame properties (schema, columns, dtypes, width) that
require resolving the schema.

Fixes #21917

Signed-off-by: edvatar <88481784+toroleapinc@users.noreply.github.com>
@alexander-beedie alexander-beedie changed the title fix: issue PerformanceWarning in LazyFrame.__contains__ fix: issue PerformanceWarning in LazyFrame.__contains__ Feb 27, 2026
@alexander-beedie alexander-beedie changed the title fix: issue PerformanceWarning in LazyFrame.__contains__ fix: Issue PerformanceWarning in LazyFrame.__contains__ Feb 27, 2026
@github-actions github-actions Bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars and removed title needs formatting labels Feb 27, 2026
@orlp

orlp commented Mar 2, 2026

Copy link
Copy Markdown
Member

Did you follow the AI policy?

@toroleapinc

Copy link
Copy Markdown
Contributor Author

Yes

@codecov

codecov Bot commented Mar 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.67%. Comparing base (9d60226) to head (9f553de).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #26734      +/-   ##
==========================================
+ Coverage   81.00%   81.67%   +0.67%     
==========================================
  Files        1805     1805              
  Lines      248021   248022       +1     
  Branches     3132     3132              
==========================================
+ Hits       200902   202569    +1667     
+ Misses      46313    44647    -1666     
  Partials      806      806              

☔ View full report in Codecov by Sentry.
📢 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.

@nameexhaustion nameexhaustion changed the title fix: Issue PerformanceWarning in LazyFrame.__contains__ fix(python): Issue PerformanceWarning in LazyFrame.__contains__ Mar 10, 2026
@nameexhaustion
nameexhaustion merged commit 105f8a0 into pola-rs:main Mar 10, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix python Related to Python Polars rust Related to Rust Polars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LazyFrame.__contains__ does not issue PerformanceWarning

3 participants