refactor!: Replace eager: bool with "lazy-in-lazy-out" - #372
Merged
Conversation
Oliver Borchert (borchero)
requested review from
Andreas Albert (AndreasAlbertQC) and
Daniel Elsner (delsner)
as code owners
July 23, 2026 12:38
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## no-group-by #372 +/- ##
=============================================
Coverage 100.00% 100.00%
=============================================
Files 46 46
Lines 2584 2590 +6
=============================================
+ Hits 2584 2590 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the eager: bool toggle from schema-level validation/filtering APIs in favor of Polars-style “lazy-in-lazy-out / eager-in-eager-out” behavior, and introduces a lazy: bool switch for collection-level validation/filtering to control whether collections are returned lazily (with restrictions when eager members exist).
Changes:
- Refactored
Schema.validate/Schema.filterto determine eager vs lazy behavior from the input frame type rather than aneagerflag. - Updated
Collection.validate/Collection.filterto uselazy: bool(defaultFalse) and added validation thatlazy=Truecannot be used when the collection has eager members. - Updated tests and benchmarks to match the new API and semantics.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/schema/test_validate.py | Removes eager parametrization and adjusts expectations based on input frame type. |
| tests/schema/test_filter.py | Updates helper and tests to rely on input frame type for eager vs lazy filtering behavior. |
| tests/collection/test_skip_member_validation.py | Migrates collection calls from eager=False to lazy=True. |
| tests/collection/test_filter_validate.py | Renames eager parametrization to lazy and updates calls accordingly. |
| tests/collection/test_dataframe_members.py | Adds coverage ensuring lazy=True is rejected for collections with eager members. |
| tests/benches/test_schema.py | Adjusts benchmark to validate either eager or lazy inputs without eager=. |
| tests/benches/test_collection.py | Updates benchmark to use lazy=True for collection filtering. |
| dataframely/schema.py | Removes eager parameter and implements type-driven eager vs lazy semantics; adds Polars-version guard for efficient filtering. |
| dataframely/collection/collection.py | Replaces eager with lazy, enforces eager-member restriction, and updates eager vs lazy execution paths. |
Comments suppressed due to low confidence (1)
dataframely/collection/collection.py:599
- Collection.filter's docstring claims member frames are always eagerly collected, but the new
lazyparameter allows returning a fully lazy result. The parameter description should reflect the conditional behavior.
All data frames passed here will be eagerly collected within the method,
regardless of whether they are a :class:`~polars.DataFrame` or
:class:`~polars.LazyFrame`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Currently, we have a parameter
eager: boolto govern whether validation and filtering is performed eagerly or lazily. This is a little inconsistent with what one would expect when familiar with the polars API:collect.sink_parquet: by default, wecollect, but this can be "disabled" by settinglazy=True(unless the collection defines at least one eager member).