You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(expressions): add truthiness semantics for constant boolean expressions
`AlwaysTrue`/`AlwaysFalse` extend `IcebergRootModel[bool]` but defined no
`__bool__`, so they used default object truthiness and were both always truthy.
That made `bool(AlwaysFalse())` return `True`, so intuitive control-flow patterns
(`if not visit_starts_with(...)`, `expr or AlwaysTrue()`) behaved incorrectly for
the FALSE constant.
Define `__bool__` on the two constants (`True`/`False`) and make the base
`BooleanExpression.__bool__` raise `TypeError`, so truthiness is only defined for
the constants and an accidental `if predicate:` is an explicit error rather than a
silently-true no-op. `not expr` returns a Python bool; `~expr` still returns the
negated expression.
Per the audit kevinjqliu requested on the issue, fix the one optional-expression
check that relied on truthiness instead of presence: REST scan-planning residual
handling (`FileScanTask.from_rest_response`) now uses `is not None`, so an explicit
residual filter is preserved and not treated as missing. Also update the
`expr or AlwaysTrue()` default in the pyarrow `project` test helper.
Tests cover constant truthiness, control-flow branching, `TypeError` for
non-constant expressions, and the REST residual path.
Closes#3543
0 commit comments