[ https://issues.apache.org/jira/browse/FLINK-1032?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14160256#comment-14160256 ]
ASF GitHub Bot commented on FLINK-1032: --------------------------------------- Github user rmetzger commented on a diff in the pull request: https://github.com/apache/incubator-flink/pull/141#discussion_r18454177 --- Diff: flink-java/src/main/java/org/apache/flink/api/java/typeutils/PojoTypeInfo.java --- @@ -105,73 +114,124 @@ public String toString() { + ", fields = [" + Joiner.on(", ").join(fieldStrings) + "]" + ">"; } - - public int getLogicalPosition(String fieldExpression) { - for (int i = 0; i < fields.length; i++) { - if (fields[i].field.getName().equals(fieldExpression)) { - return i; + + @Override + public void getKey(String fieldExpression, int offset, List<FlatFieldDescriptor> result) { + // handle 'select all' first + if(fieldExpression.equals(ExpressionKeys.SELECT_ALL_CHAR)) { + int keyPosition = 0; + for(PojoField field : fields) { + if(field.type instanceof AtomicType) { + result.add(new FlatFieldDescriptor(offset + keyPosition, field.type)); + } else if(field.type instanceof CompositeType) { + CompositeType<?> cType = (CompositeType<?>)field.type; + cType.getKey(String.valueOf(ExpressionKeys.SELECT_ALL_CHAR), offset + keyPosition, result); + keyPosition += cType.getTotalFields()-1; + } else { + throw new RuntimeException("Unexpected key type: "+field.type); + } + keyPosition++; } + return; + } + Validate.notEmpty(fieldExpression, "Field expression must not be empty."); + // if there is a dot try getting the field from that sub field + int firstDot = fieldExpression.indexOf('.'); + if (firstDot == -1) { + // this is the last field (or only field) in the field expression + int fieldId = 0; + for (int i = 0; i < fields.length; i++) { + if(fields[i].type instanceof CompositeType) { + fieldId += fields[i].type.getTotalFields()-1; + } --- End diff -- Thank you. I've fixed this > Extend POJO Field Selectors to Support Accessing Nested Objects > --------------------------------------------------------------- > > Key: FLINK-1032 > URL: https://issues.apache.org/jira/browse/FLINK-1032 > Project: Flink > Issue Type: Sub-task > Components: Java API > Reporter: Aljoscha Krettek > Assignee: Robert Metzger > > Right now you can only use fields of the top-level object as key fields in > groupings, joins, and co-group. This should be extended to allow using nested > fields. We have to be careful with null fields, though. -- This message was sent by Atlassian JIRA (v6.3.4#6332)