Repository navigation
feat(condition): a boolean column is a condition; ~col(c) is its negation - #673
Conversation
…tion (ITL-1769)
filter(col("flag")) keeps the rows where flag is true and filter(~col("flag"))
the rows where it is false. A bare reference stands for col(c) == True and its
negation for col(c) == False, so the identity, saved form and SpiralDB
push-down are those of the existing equalities: no new condition kind and no
hash moves. A null is kept by neither. A bare column combines through & and |
and is accepted by filter, Filter, Condition.of and SpiralDB where. A column
that is not boolean is refused when the condition meets the stream, with a hint.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Boolean condition semantics src/orcapod/types/condition.py, tests/test_types_condition_tree.py |
ColumnRef supports true and false conditions and composition with & and |. Condition.of and condition operators accept references. Tests cover invalid operands and type guidance. |
Stream filter integration src/orcapod/core/operators/filter.py, src/orcapod/core/streams/base.py, src/orcapod/protocols/core_protocols/streams.py, tests/test_core/operators/test_filter_boolean_column.py, docs/concepts/operators.md, changelog.d/ITL-1777.md |
Filter APIs accept ColumnRef conditions. Tests cover row selection, null handling, condition identity and saved forms, and sync and async execution. Documentation and the changelog describe the shorthand. |
SpiralDB where integration src/orcapod/core/sources/spiraldb_table_source.py, tests/test_core/operators/test_filter_boolean_column.py |
SpiralDBTableSource.where accepts column references. Tests verify translation to equality predicates and rejection of non-boolean columns and OR conditions. |
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Feature
Possibly related PRs
- metamorphic-labs/orcapod-python#498: Covers the same filter condition forms, null behavior, identity, saved forms, and
where/filtercomparisons. - metamorphic-labs/orcapod-python#493: Introduces the
Conditiontype and equality restrictions that this change extends for boolean column references.
Merge Risk: 
Minimal · up to f8cd9
-
Bare boolean columns now work as filter and where conditions. The change is additive, reuses existing equality semantics, and no concrete merge-blocking risk was identified.
Security architecture risk: 
Minimal · up to f8cd9
-
The new syntax expresses boolean filters that callers could already write. It keeps the same validation, saved representation, and database access scope. No material security or rollback regression was identified in the reviewed change.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — The additional caller input can select the same rows as an explicit boolean equality on the already selected stream or table. It does not select a new table, change the configured client, or grant new read authority.
Trust Boundaries and Controls
- observed — At the SpiralDB read boundary, the connector refuses unsupported term shapes and builds equality from a column expression and a typed literal. The scan still runs through the existing read service call for the resolved table.
-
Pre-merge checks: 
4
-
Full details: Title check
-
Explanation
The title names the main change: a bare boolean column becomes a filter condition, and ~col(c) is its negation. The changeset adds ColumnRef support in Condition.of, Filter, StreamBase.filter, and SpiralDB where, plus the boolean-column shorthand and its negation. The title is specific and matches the primary change. It uses the conventional feat(condition) prefix and stays under one sentence.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Usage-based review receipt
- Mode: Review on demand
- Reviewed files: 9
- Charged: $2.25
- View usage details
Note
This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.
Fixes ITL-1777
What
stream.filter(col("flag"))keeps the rows where the boolean columnflagis true, andstream.filter(~col("flag"))the rows where it is false. A null is neither true nor false, so a row with a null is kept by neither, as conditions already state (Kleene logic).Design: no new condition kind
A bare reference given where a condition is taken is the existing equality:
col("flag")(orcol("flag").is_true())col("flag") == True~col("flag")col("flag") == FalseFilteridentity is("Filter", condition.canonical_form()), as before.filter(col("flag")),filter(col("flag") == True)andfilter(flag=True)are one condition with one hash.~col("flag")isfilter(flag=False), so it differs from the plain form. No new tree node, canonical form or saved form exists. The order of&/|operands and of arguments never counts, because the existing canonical form sorts them (tested).{"flag": true}/{"flag": false}, or the tree form when combined. It reads back as the same condition.ColumnRefgains__invert__,__and__/__rand__and__or__/__ror__, andCondition.__and__/__or__accept aColumnRef.Condition.of(sofilter,Filterandwhere) accepts a bareColumnRefpositionally. Anything else (& True,| "x") is still refused.not col(c)andcol(a) and col(b)still raise (no truth value).Filter, from the stream's Python schema; for a struct field, when applied; atwhere()for SpiralDB). The existing value-type error gains a hint: "A bare col(c) stands for col(c) == True and ~col(c) for col(c) == False: both take a boolean column only". The type is never known whencol()is built, so validation time is the earliest point.where. The two forms are the equalitiesflag == True/flag == Falsethatcheck_restrictionalready accepts. The connector already sends them assp.eq(column, literal(bool)), which keeps no null row. That is exactly Orcapod's rule, so the push-down is exact.|and a negation of a condition stay refused bywhere, as before.One existing test changed:
tests/test_types_condition_tree.py::test_and_with_something_else_is_refusedasserted thatcondition | col("u")is refused. That combination is now the feature, so the test uses| "u"instead.Proof (
tests/test_core/operators/test_filter_boolean_column.py)&,|,~and separate arguments or keywords. Each runs in both operand orders, on two tag orders and two table layouts.== Trueandflag=True(condition, content hash, pipeline hash,identity_structure).~equals== False. The negation differs from the plain form. Equal conditions written in different orders give equal canonical forms, saved forms and hashes.flag == True/flag == False. Rows matchfilter, two boolean columns work in both orders, the restriction keeps the source identity, a non-bool column is refused, and|stays refused.Checks
generate_golden_hashes.py --check: every golden value matches; no entry added.design_issues.py --check,assemble_changelog.py --check.where, async/sync equivalence, several-items, order invariance and the operators doc sample.Docs: a "boolean column" row and an executed example in the Filter section of
docs/concepts/operators.md. Changelog:changelog.d/ITL-1777.md.🤖 Generated with Claude Code
Summary by CodeRabbit
col("flag")keeps true rows, while~col("flag")keeps false rows. Combine these conditions with AND and OR.whereclauses.