kevinjqliu opened a new issue, #3543:
URL: https://github.com/apache/iceberg-python/issues/3543

   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_
               


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to