Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Add explicit truthiness semantics for constant BooleanExpressions

Open
#3,543 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
databases

Research direction

Start by locating BooleanExpression, AlwaysTrue, and AlwaysFalse, then inspect the optional-expression checks and REST residual/filter handling mentioned in the issue. Verify that only constant expressions support Python truthiness, non-constant expressions reject it, and explicit AlwaysFalse() values are preserved rather than treated as missing.

Written by the indexing model from the issue text.

Description

While this PR can use expression negation via __invert__, I think it may be worth supporting Python truthiness for the constant expressions in a follow-up:

class AlwaysTrue:
    def __bool__(self) -> bool:
        return True

class AlwaysFalse:
    def __bool__(self) -> bool:
        return False

That would make patterns like this behave intuitively:

        if not self.visit_starts_with(term, literal):
            return AlwaysTrue()

When adding this, we should also be careful that Python truthiness is for control flow, not expression construction: not expr returns a Python bool, while ~expr returns a negated BooleanExpression. It would probably be safest for non-constant BooleanExpression.__bool__ to raise, with only AlwaysTrue and AlwaysFalse overriding it. The follow-up should also audit optional-expression checks like expr or AlwaysTrue() and REST residual/filter handling so explicit AlwaysFalse() values are not treated as missing.

Originally posted by @kevinjqliu in https://github.com/apache/iceberg-python/issues/3503#issuecomment-4763176953

Dominant language
Python
Stars
1.1k
Forks
589
Avg merge
2d 4h
Merged PRs (30d)
72

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/iceberg-python

All issues in apache/iceberg-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.