apache / apache/iceberg-python

Add explicit truthiness semantics for constant BooleanExpressions

未關閉
#3,543 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
1.1k
分支
581
平均合併
1 天 13 小時
30 天內合併 PR
76

描述

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_

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

先定位 BooleanExpression、AlwaysTrue 和 AlwaysFalse,接著檢查 issue 中提到的選用表達式檢查以及 REST residual/filter 處理。確認只有常數表達式支援 Python truthiness,非​​常數表達式會拒絕它,且明確的 AlwaysFalse() 值會被保留,而不是被視為缺少。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
databases
Issue 類型
功能
難度
4/5
預估耗時
3-5 天
活躍度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。