refactor!: Replace eager: bool with "lazy-in-lazy-out"#372
Open
Oliver Borchert (borchero) wants to merge 1 commit into
Open
refactor!: Replace eager: bool with "lazy-in-lazy-out"#372Oliver Borchert (borchero) wants to merge 1 commit into
eager: bool with "lazy-in-lazy-out"#372Oliver Borchert (borchero) wants to merge 1 commit into
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 @@
## main #372 +/- ##
========================================
Coverage ? 100.00%
========================================
Files ? 56
Lines ? 3513
Branches ? 0
========================================
Hits ? 3513
Misses ? 0
Partials ? 0 ☔ 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`.
Comment on lines
+561
to
+563
| SchemaError: If the input data frame is eager and it misses columns or | ||
| `cast=False` and any data type mismatches the definition in this | ||
| schema. Only raised upon collection if `eager=False`. | ||
| ValidationError: If `eager=True` and in any rule in the schema is | ||
| violated, i.e. the data does not pass the validation. When | ||
| `eager=False`, a :class:`~polars.exceptions.ComputeError` is raised | ||
| Only raised upon collection if the input data frame is lazy. |
Comment on lines
+429
to
433
| ValidationError: If `lazy=False` and any of the input data frames does not | ||
| satisfy its schema definition or the filters on this collection result | ||
| in the removal of at least one row across any of the input data frames. | ||
| If `eager=False`, a :class:`~polars.exceptions.ComputeError` is raised | ||
| If `lazy=False`, a :class:`~polars.exceptions.ComputeError` is raised | ||
| upon collecting. |
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).