Skip to content

feat: Raise early errors when sampling - #433

Merged
Oliver Borchert (borchero) merged 3 commits into
mainfrom
early-error
Dec 4, 2026
Merged

Oliver Borchert (borchero) merged 3 commits into
mainfrom
early-error

Conversation

@borchero

Copy link
Copy Markdown
Member

Motivation

Fixes #429.

Thanks Brendan Cooley (@brendancooley) for raising :)

@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (51af31b) to head (64ae790).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #433   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           46        46           
  Lines         2601      2611   +10     
=========================================
+ Hits          2601      2611   +10     

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Sampling validation can incorrectly reject valid samples because selector dependencies are missed and empty-column projections discard the intended row count.

2 open issues
What changed in this PR

This PR addresses #429 by making Schema.sample reject invalid overrides early and report more relevant sampling failures.

Changes:

  • Validate rules determined entirely by fixed overrides before sampling.
  • Report failures from the last sampling iteration using shared formatting.
  • Add tests for early errors, override holes, and cross-column checks.
File Description
tests/​schema/​test_sample.py Updates error expectations and adds override-validation tests.
dataframely/​schema.py Adds early override checks and improves sampling failure reporting.

Review effort: Balanced

Comment thread dataframely/schema.py Resolved
Comment thread dataframely/schema.py Resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 2, 2026 01:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Prevalidation loses the row count when every override column contains holes, causing column-independent rules to reject valid overrides or accept impossible sampling requests.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Reduce the fail-fast regression test to one sampling iteration

tests/​schema/​test_sample.py:276

If fail-fast validation regresses, this test can run one million sampling rounds before failing, potentially tying up CI for hours. The expected early-error message already distinguishes prevalidation from iteration exhaustion, so one iteration is sufficient and makes regressions fail quickly.

2 resolved since last review

Review effort: Balanced

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, looks good to me!

Comment thread dataframely/schema.py Resolved
Comment thread dataframely/schema.py Resolved
Copilot AI balanced review requested due to automatic review settings December 4, 2026 00:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

A critical issue remains: with failure examples enabled, a column-level check can trigger a Rust panic instead of ValueError when its owning column is absent from fixed_columns.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

High severity Avoid panics when failure examples select an absent checked column

dataframely/​schema.py:372

With max_failure_examples > 0, a check such as b = dy.Int64(check=lambda _: pl.col("a") > 0) with only a=[-1] overridden causes a Rust panic instead of ValueError. The check is selected, but RuleFailureInfo::new tries to select the absent b column for examples and unwraps the error. Also require the owning column to be present in fixed_columns before selecting column-level rules.

Review effort: Balanced

@borchero
Oliver Borchert (borchero) merged commit 367360c into main Dec 4, 2026
33 checks passed
@borchero
Oliver Borchert (borchero) deleted the early-error branch December 4, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Schema.sample fails fast when overrides are invalid

4 participants