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_r269251205
##########
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:
@xabriel I'm now creating an index that keeps ids to accessors and then use
accessors to reach type and fields. access to this index is lazy as well.
----------------------------------------------------------------
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]