feat: add expression visitors#311
Conversation
f88a20f to
b541297
Compare
- Add template ExpressionVisitor and BoundVisitor - Implement Binder, IsBoundVisitor and RewriteNot
Co-authored-by: Zehua Zou <zehuazou2000@gmail.com>
Co-authored-by: Zehua Zou <zehuazou2000@gmail.com>
Co-authored-by: Zehua Zou <zehuazou2000@gmail.com>
Co-authored-by: Zehua Zou <zehuazou2000@gmail.com>
Co-authored-by: Zehua Zou <zehuazou2000@gmail.com>
Co-authored-by: Zehua Zou <zehuazou2000@gmail.com>
Co-authored-by: Zehua Zou <zehuazou2000@gmail.com>
Co-authored-by: Zehua Zou <zehuazou2000@gmail.com>
zhjwpku
left a comment
There was a problem hiding this comment.
+1, thanks for working on this.
| } | ||
|
|
||
| Result<bool> IsBoundVisitor::Or(bool left_result, bool right_result) { | ||
| return left_result && right_result; |
There was a problem hiding this comment.
| return left_result && right_result; | |
| return left_result || right_result; |
There was a problem hiding this comment.
I don't think this is correct because this is not a logical operation. We can only return true if both sides are bound expressions. See java impl for reference: https://github.com/apache/iceberg/blob/main/api/src/main/java/org/apache/iceberg/expressions/Binder.java#L208-L245
| Result<std::shared_ptr<Expression>> Binder::Predicate( | ||
| const std::shared_ptr<BoundPredicate>& pred) { | ||
| ICEBERG_DCHECK(pred != nullptr, "Predicate cannot be null"); | ||
| return InvalidExpression("Found already bound predicate: {}", pred->ToString()); |
There was a problem hiding this comment.
Does additional commentary need to be added here? If an already bound expression is encountered, choose to report an error rather than directly using it.
There was a problem hiding this comment.
Did you mean that we need to add a comment on why an error is returned here?
UnboundPredicateto use virtual inheritance ofExpressionto facilitate visitor pattern.ExpressionVisitorandBoundVisitor.Binder,IsBoundVisitorandRewriteNot.Closes #70 #71 #72