refactor!: Remove group rules in favor of over expressions - #389
Merged
Conversation
This was
linked to
issues
Jul 31, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## refine-categoricals #389 +/- ##
=====================================================
Coverage 100.00% 100.00%
=====================================================
Files 46 46
Lines 2624 2584 -40
=====================================================
- Hits 2624 2584 -40 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Oliver Borchert (borchero)
marked this pull request as ready for review
July 31, 2026 11:05
Oliver Borchert (borchero)
requested review from
Andreas Albert (AndreasAlbertQC) and
Daniel Elsner (delsner)
as code owners
July 31, 2026 11:05
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the legacy @dy.rule(group_by=...) (“group rules”) API and refactors rule evaluation to rely on native Polars window expressions (.over(...)), simplifying the internal implementation and aligning the public API/docs with the RFC in #316 while also addressing the class of issues described in #332.
Changes:
- Deleted
GroupRuleand thegroup_byparameter fromdy.rule, consolidating rule evaluation into a singlewith_columnspath. - Updated tests/benchmarks to express cross-row constraints using
.over(...)expressions instead of group rules. - Updated documentation and examples (README, quickstart, SKILL.md, notebook) to recommend
.over(...)for cross-row validation.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
dataframely/_rule.py |
Removes GroupRule and group_by support; simplifies rule evaluation to a single with_columns pass. |
dataframely/_base_schema.py |
Removes schema-time validation specific to GroupRule group columns. |
tests/schema/test_validate.py |
Migrates a group-rule-based test to .over(...) and adds a regression test for dynamic boolean column selection. |
tests/schema/test_sample.py |
Updates sample-rule schemas to use .over(...) instead of group_by. |
tests/schema/test_rule_implementation.py |
Removes tests specific to GroupRule behaviors and group_by="primary_key". |
tests/schema/test_repr.py |
Updates expected schema repr to reflect .over(...) expressions. |
tests/schema/test_matches.py |
Removes GroupRule match/inequality coverage, leaving Rule matching only. |
tests/schema/test_filter.py |
Updates filter-order test to use .over(...) instead of GroupRule. |
tests/core_validation/test_rule_evaluation.py |
Removes tests that exercised group-rule evaluation via GroupRule. |
tests/benches/test_schema.py |
Renames benchmark schemas and rewrites rules to use .over(...). |
skills/SKILL.md |
Updates guidance to recommend over expressions rather than group rules. |
README.md |
Updates the quick example from group_by to .over(...). |
docs/guides/quickstart.md |
Removes the “Group rules” section and replaces it with a note about .over(...). |
docs/guides/faq.md |
Updates the uniqueness example to use .over(...). |
docs/guides/examples/real-world.ipynb |
Updates real-world examples to use .over(...) and removes mention of group_by. |
Andreas Albert (AndreasAlbertQC)
approved these changes
Jul 31, 2026
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
Resolves #316, #332.
Supersedes #374.