prodeezy commented on a change in pull request #123: Add support for struct 
field based filtering
URL: https://github.com/apache/incubator-iceberg/pull/123#discussion_r266409609
 
 

 ##########
 File path: 
api/src/main/java/com/netflix/iceberg/expressions/UnboundPredicate.java
 ##########
 @@ -132,4 +134,36 @@ public Expression bind(Types.StructType struct, boolean 
caseSensitive) {
     }
     return new BoundPredicate<>(op(), new BoundReference<>(struct, 
field.fieldId()), lit);
   }
+
+  private Types.NestedField findNestedField(Types.StructType struct, String 
expressionFieldPath,
+    boolean caseSensitive) {
+
+    String[] nestedFields = expressionFieldPath.split("\\.");
+    String lastFieldInPath = nestedFields[nestedFields.length - 1];
+
+    Types.StructType subField = struct;
+    int i=0;
+
+    Type nextFieldType = caseSensitive ? 
subField.field(nestedFields[i]).type() :
+      subField.caseInsensitiveField(nestedFields[i]).type();
+
+    if (!(nextFieldType instanceof Types.StructType)) {
+      // we don't handle non-struct nested fields yet
+      return null;
+    }
+
+    while(nextFieldType instanceof Types.StructType && i < 
nestedFields.length) {
+
+      subField = caseSensitive ? 
subField.field(nestedFields[i]).type().asStructType() :
+        subField.caseInsensitiveField(nestedFields[i]).type().asStructType();
+
+      i++;
+
+      nextFieldType = caseSensitive ? subField.field(nestedFields[i]).type() :
+        subField.caseInsensitiveField(nestedFields[i]).type();
+    }
+
+    return subField.field(lastFieldInPath);
+
+  }
 
 Review comment:
   Right. seems like it's being called many times but by different expression 
evaluators. A cache to lookup field name to Types.NestedField would help. Good 
call.  will add one in. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to