feat: Allow FailureInfo to persist only failing rule columns - #400
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The implementation matches the stated behavior, keeps parquet metadata consistent, preserves default lossless behavior, and includes targeted tests and documentation for key edge cases.
Pull request overview
This PR adds an opt-in serialization mode to reduce the width of persisted FailureInfo parquet files by writing only rule-output columns that actually contain at least one failing (False) value, addressing issue #296.
Changes:
- Added keyword-only
only_invalid_rulestoFailureInfo.write_parquet()to omit always-successful / unknown-only rule columns when enabled. - Adjusted
FailureInfo.details()to handle the edge case of an emptyrule_columnslist. - Added tests and documentation covering reduced serialization, metadata consistency, and round-tripping (including empty failure info).
File summaries
| File | Description |
|---|---|
| tests/failure_info/test_parquet.py | Adds fixtures and tests for reduced parquet serialization, metadata, and round-trip behavior (eager + scan). |
| docs/guides/features/serialization.md | Documents the new only_invalid_rules=True option and its intentionally lossy semantics. |
| dataframely/filter_result.py | Implements only_invalid_rules in FailureInfo.write_parquet() and handles empty rule-columns in details(). |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Oliver Borchert (borchero)
left a comment
There was a problem hiding this comment.
Thank you for the contribution Danila Pechenev (@Danila-Pechenev)! Just some small suggestions
| if len(self._rule_columns) == 0: | ||
| return self.invalid() | ||
|
|
There was a problem hiding this comment.
Why is this necessary?
There was a problem hiding this comment.
This is needed for an empty FailureInfo persisted with only_failing_rules=True. Since no rule contains a failure, the reduced representation has rule_columns=[]. After reading/scanning it back, details() would otherwise call pl.col() and raise a TypeError. Returning invalid() makes details() work for that reduced state as well.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #400 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 46 46
Lines 2590 2598 +8
=========================================
+ Hits 2590 2598 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Motivation
Fixes #296.
Persisted
FailureInfoobjects can become very wide because they include an output column for every validation rule, even when most rules never fail.Changes
only_invalid_rulesoption toFailureInfo.write_parquet().False.Testing