dino-saurabh commented on code in PR #1181:
URL: https://github.com/apache/iceberg-cpp/pull/1181#discussion_r4716409816
##########
src/iceberg/expression/expression_visitor.h:
##########
@@ -329,4 +329,52 @@ Result<R> Visit(const std::shared_ptr<Expression>& expr,
V& visitor) {
}
}
+/// \brief Traverse an expression tree with a boolean visitor,
short-circuiting And/Or.
+///
+/// Like Visit, but skips the right child of an And when the left child is
false and of
+/// an Or when the left child is true, so errors from a skipped child are not
reported.
+/// Mirrors Java's ExpressionVisitors.visitEvaluator.
+///
+/// \tparam V The visitor type (must derive from ExpressionVisitor<bool>)
+/// \param expr The expression to traverse
+/// \param visitor The visitor to use for traversal
+/// \return The result produced by the visitor for the root expression node
+template <typename V>
+ requires std::derived_from<V, ExpressionVisitor<bool>>
+Result<bool> VisitEvaluator(const std::shared_ptr<Expression>& expr, V&
visitor) {
+ ICEBERG_DCHECK(expr != nullptr, "Expression cannot be null");
+
+ switch (expr->op()) {
Review Comment:
gotcha fixed.
##########
src/iceberg/expression/evaluator.cc:
##########
@@ -153,7 +153,7 @@ Result<std::unique_ptr<Evaluator>> Evaluator::Make(const
Schema& schema,
Result<bool> Evaluator::Evaluate(const StructLike& row) const {
EvalVisitor visitor(row);
- return Visit<bool, EvalVisitor>(bound_expr_, visitor);
+ return VisitEvaluator(bound_expr_, visitor);
Review Comment:
ah yes let me rebase.
--
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]