← Back to Pull requests

[feature] Add write_batch_size to cache_parquet #86

Closed
unknown closed this pull request without merging on Oct 21, 2026 12:54 UTC
View on GitHub
unknown unknown commented on Oct 20, 2026 19:27 UTC
Author

Description

cache_parquet writes all missing partitions in one streaming sink, and Polars renames each finished file into place only when the sink ends. A backfill that fails or is killed partway keeps none of its partitions. This adds write_batch_size, which splits the write into upstream queries of at most that many partitions, so every batch that completes stays in the cache and a rerun fetches only the rest.

  • Batches follow partition order. Each runs the source again with a filter for its own partitions, so the source must return the same data each time. Batching applies under CacheMode.CACHE when the query's partitions can be enumerated and none of its keys is null; other writes are not split.

  • Each batch writes its empty partitions (gaps and expired files that upstream no longer fills) as it completes, so a later failure does not refetch them. Gaps are found by comparing partition values, as on main, so a batch that writes 0.0 for a query on -0.0 does not empty it; the signed-zero regression test now also runs with write_batch_size=1.

  • The write filter now selects only the target partitions. It previously selected every combination of the target dates and extra-column values (a target of (d1, A) and (d2, B) also wrote (d1, B) and (d2, A)), and it dropped a target with a null date and no extra-column constraint. Both affect unbatched writes too. Periods that target the same extra-column values share one filter term, so the filter stays small for long date ranges.

  • The open-sink error now suggests write_batch_size, and the docstring notes how a ttl with a fixed cutoff gives a REBUILD that a rerun can resume.

  • The API reference shows the expected way to retry a backfill: run the query again in a loop, which fetches only the partitions not yet written. Source errors reach the caller as ComputeError with the original message but not its type, so the example catches that.
  • Type of Change

  • Bug fix

  • New feature

  • Documentation update

  • Refactor / code cleanup

  • CI / build configuration

  • Other (describe below)
  • Checklist

  • Linting passes (make lint-py, make lint-docs)

  • Tests pass (python -m pytest polars_io_tools/tests --ignore=polars_io_tools/tests/integration: 2163 passed with Polars 2.0.0, 2160 with Polars 1.44.1)

  • New tests added for new functionality

  • Documentation updated (if applicable)

  • Changelog / version bump (if applicable)
  • Diff: 309 lines (+231 / -78) across 3 files Reviewer: timkpaine Review duration: 1046m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 309 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.343
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #86"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.2% (MEDIUM) · Higher = larger blast radius
    40.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.9% · Safe to merge
    15.9%