huaxingao commented on code in PR #4938:
URL: https://github.com/apache/iceberg/pull/4938#discussion_r890211588


##########
api/src/main/java/org/apache/iceberg/expressions/Binder.java:
##########
@@ -91,12 +91,21 @@ static Expression bind(StructType struct,
   }
 
   public static Set<Integer> boundReferences(StructType struct, 
List<Expression> exprs, boolean caseSensitive) {
+    return references(struct, exprs, caseSensitive, false);
+  }
+
+  public static Set<Integer> references(
+      StructType struct, List<Expression> exprs, boolean caseSensitive, 
boolean alreadyBound) {

Review Comment:
   Can i just use `instanceof Unbound` to detect if an expression is unbound? 
Something like this:
   
   ```
     private static boolean isUnbound(Expression expr) {
       switch (expr.op()) {
         case TRUE:
           return false;
         case FALSE:
           return false;
         case NOT:
           Not not = (Not) expr;
           return isUnbound(not.child());
         case AND:
           And and = (And) expr;
           return isUnbound(and.left()) || isUnbound(and.right());
         case OR:
           Or or = (Or) expr;
           return isUnbound(or.left()) || isUnbound(or.right());
         default:
           return expr instanceof Unbound;
       }
     }
   ```
   Then the method `boundReferences` can be
   ```
     public static Set<Integer> boundReferences(StructType struct, 
List<Expression> exprs, boolean caseSensitive) {
       if (exprs == null) {
         return ImmutableSet.of();
       }
       ReferenceVisitor visitor = new ReferenceVisitor();
       for (Expression expr : exprs) {
         if (isUnbound(expr)) {
           ExpressionVisitors.visit(bind(struct, expr, caseSensitive), visitor);
         } else {
           ExpressionVisitors.visit(expr, visitor);
         }
       }
       return visitor.references;
     }
   ```



-- 
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]

Reply via email to