Skip to content

Conversation

@wgtmac
Copy link
Member

@wgtmac wgtmac commented Nov 11, 2025

  • Added support to And/Or/Not to create folded expressions.
  • Refactored UnboundPredicate to use virtual inheritance of Expression to facilitate visitor pattern.
  • Added template class ExpressionVisitor and BoundVisitor.
  • Implemented Binder, IsBoundVisitor and RewriteNot.

Closes #70 #71 #72

@wgtmac wgtmac force-pushed the expr_visitor branch 2 times, most recently from f88a20f to b541297 Compare November 11, 2025 15:56
- Add template ExpressionVisitor and BoundVisitor
- Implement Binder, IsBoundVisitor and RewriteNot
wgtmac and others added 4 commits November 13, 2025 23:17
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>
wgtmac and others added 4 commits November 14, 2025 17:36
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>
Copy link
Contributor

@HuaHuaY HuaHuaY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@zhjwpku zhjwpku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, thanks for working on this.

}

Result<bool> IsBoundVisitor::Or(bool left_result, bool right_result) {
return left_result && right_result;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return left_result && right_result;
return left_result || right_result;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean that we need to add a comment on why an error is returned here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ExpressionVisitor to evaluate expressions

5 participants