apache / apache/iceberg-python
Add explicit truthiness semantics for constant BooleanExpressions
- Lenguaje dominante
- Python
- Estrellas
- 1.1k
- Forks
- 581
- Merge medio
- 1 d 17 h
- PR fusionados (30 d)
- 78
Descripción
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_
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Empieza localizando BooleanExpression, AlwaysTrue y AlwaysFalse; después, inspecciona las comprobaciones de expresiones opcionales y el manejo de residuales/filtros de REST mencionados en el issue. Verifica que solo las expresiones constantes admitan la evaluación de verdad de Python, que las expresiones no constantes la rechacen y que los valores explícitos AlwaysFalse() se conserven en lugar de tratarse como ausentes.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- databases
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100