Skip to content

feat: filter reindex rows with a polars regex op - #233

Merged
SkyeAv merged 1 commit into
feat/reindex-regex-configfrom
feat/reindex-regex-pipeline
Oct 21, 2026
Merged

SkyeAv merged 1 commit into
feat/reindex-regex-configfrom
feat/reindex-regex-pipeline

Conversation

@SkyeAv

@SkyeAv SkyeAv commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

feat: filter reindex rows with a polars regex op

Wires the Reindex.regex config flag (#232) into the pipeline: a regex entry filters rows through a new lib.reindex_regex op, while every regex-less entry keeps emitting the exact op tuples it always did, so run-cache digests do not move.

Pipeline

  • New op: lib.reindex_regex(df, col, pattern, negate) in src/tablassert/lib.py: one lazy filter over str.contains on the column cast to String, so a typed parquet column filters on its text form (22.0 matches ^2\d?\.0$) instead of raising polars' InvalidOperationError, and a null cell drops under both directions exactly as literal eq/ne drop nulls.
  • Dispatch: Tcode._source_ops emits (reindex_regex, (idxname(column), comparator, comparison == "ne")) for a regex entry; the legacy arms are byte-identical to the previous code, and x.comparison is the plain "ne"/"eq" string under TablaBase's use_enum_values.
  • Phase and cost tables: lib.PHASE_OF and runcache.OP_COST both carry the new op, keeping test_op_cost_covers_every_phase_of_callable green.

Backwards compatibility

  • Digest pin: test_reindex_dispatch_keeps_legacy_ops_and_digests asserts the emitted tuples equal the literal pre-feature tuples AND that prefix_digest is unchanged for a regex-less config, so existing builds neither rebuild nor change which rows survive.

Testing

  • uv run pytest tests/test_cover_lib.py -k reindex -n 0 --no-cov -q -> 9 passed (match, negate, unanchored search, typed-column cast, null rows, legacy tuple + digest pin, regex dispatch for both comparisons).
  • uv run pytest tests/test_production_patterns.py -k reindex -n 0 --no-cov -q -> 10 passed (end-to-end builds: ne over a junk family, eq shape, anchored ne).
  • uv run pytest tests/test_run_cache.py -n 0 --no-cov -q -> 34 passed.
  • uv run pytest -n 8 -q -> 1277 passed, 1 skipped (the skip is the opt-in TABLASSERT_CONFIG_CORPUS sweep), coverage 98%.

@SkyeAv
SkyeAv added this pull request to stack #235 October 21, 2026 21:09
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b7021ba5-b001-4d24-a2b4-52cffa7827db
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Add lib.reindex_regex(df, col, pattern, negate): one lazy filter over
str.contains on the column cast to String, so a typed parquet column filters on
its text form instead of raising InvalidOperationError, and a null cell drops
under both directions exactly as literal eq/ne drop nulls. Tcode._source_ops
emits it for a regex entry with the negate flag derived from the comparison;
regex-less entries keep emitting the exact tuples they always did, so run-cache
op digests do not move (pinned by the new dispatch test against the literal
pre-feature tuples and their digest). PHASE_OF and runcache.OP_COST both carry
the new op, keeping the exhaustiveness pin green.

End-to-end: a build with regex ne over several missing-value spellings emits
only the surviving rows' edges, and an anchored pattern proves anchoring is the
config author's job.
@SkyeAv
SkyeAv force-pushed the feat/reindex-regex-pipeline branch from c9eab69 to 5177618 Compare October 21, 2026 21:43
@SkyeAv
SkyeAv merged commit 9fd22b1 into main Oct 21, 2026
5 of 11 checks passed
SkyeAv added a commit that referenced this pull request Oct 22, 2026
Cut 22.2.0 and bump the package version in pyproject.toml,
CITATION.cff, and uv.lock.

Minor: the --qc study stage fails the build on self-referential
edges via a new self-loop-edges assertion (#229); eq/ne reindex
filters can match cells with a Polars regex behind a default-off
regex key (#232, #233, #234); source.reindex can filter rows by
identifier membership with join/antijoin semi/anti hash joins
(#236). Docs: the Taxon Filtering link in the table config
reference now matches its section (#228, #231).

Changelog:
- Versioned the Unreleased section as 22.2.0 - 2026-10-22.
- Added PR links to the three Added entries (#229; #232, #233,
  #234; #236).
- Added the missing Fixed entry for the Taxon Filtering docs link
  (#228, #231).

Docs: none needed here; the shipped docs changes are covered by
the changelog entries above.

Testing:
- make check -> ruff, ruff format, pyright, pytest, cargo test,
  cargo clippy -D warnings: all green.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant