Skip to content

Add explicit truthiness semantics for constant BooleanExpressions (#3543) - #4427

Open
Yshuro wants to merge 2 commits into
apache:mainfrom
Yshuro:feature/boolean-expression-truthiness
Open

Yshuro wants to merge 2 commits into
apache:mainfrom
Yshuro:feature/boolean-expression-truthiness

Conversation

@Yshuro

@Yshuro Yshuro commented Nov 19, 2026

Copy link
Copy Markdown

Summary

Implements explicit Python truthiness semantics for BooleanExpression classes as discussed in #3543:

  • AlwaysTrue.bool evaluates to True.
  • AlwaysFalse.bool evaluates to False.
  • Non-constant BooleanExpression.bool raises TypeError to prevent accidental logic errors when using Python control flow / logical operators (
    ot, �nd, or) instead of bitwise expression operators (~, &, |).

Changes

  • pyiceberg/expressions/init.py: Implement bool on BooleanExpression (raises TypeError), AlwaysTrue (returns True), and AlwaysFalse (returns False).
  • ests/expressions/test_expressions.py: Add unit tests for truthiness evaluation and type error assertions.

Closes #3543

This branch has not been deployed

No deployments
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.

Add explicit truthiness semantics for constant BooleanExpressions

1 participant