{"record":{"id":"ba0244d3c129122e","repo":"apache/flink","slug":"nested-field-expression-not-possible-on-atomi","errorCode":null,"errorMessage":"Nested field expression \"{}\" not possible on atomic type {}.","messagePattern":"Nested field expression \"(.+?)\" not possible on atomic type (.+?)\\.","errorType":"exception","errorClass":"InvalidFieldReferenceException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/java/typeutils/PojoTypeInfo.java","lineNumber":229,"sourceCode":"                ((CompositeType<?>) fieldType).getFlatFields(\"*\", offset, result);\n            } else {\n                // we found the field to add\n                // compute flat field position by adding skipped fields\n                int flatFieldPos = offset;\n                for (int i = 0; i < fieldPos; i++) {\n                    flatFieldPos += this.getTypeAt(i).getTotalFields();\n                }\n                result.add(new FlatFieldDescriptor(flatFieldPos, fieldType));\n            }\n        } else {\n            if (fieldType instanceof CompositeType<?>) {\n                // forward offset\n                for (int i = 0; i < fieldPos; i++) {\n                    offset += this.getTypeAt(i).getTotalFields();\n                }\n                ((CompositeType<?>) fieldType).getFlatFields(tail, offset, result);\n            } else {\n                throw new InvalidFieldReferenceException(\n                        \"Nested field expression \\\"\"\n                                + tail\n                                + \"\\\" not possible on atomic type \"\n                                + fieldType\n                                + \".\");\n            }\n        }\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    @PublicEvolving\n    public <X> TypeInformation<X> getTypeAt(String fieldExpression) {\n\n        Matcher matcher = PATTERN_NESTED_FIELDS.matcher(fieldExpression);\n        if (!matcher.matches()) {\n            if (fieldExpression.startsWith(ExpressionKeys.SELECT_ALL_CHAR)\n                    || fieldExpression.startsWith(ExpressionKeys.SELECT_ALL_CHAR_SCALA)) {","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/java/typeutils/PojoTypeInfo.java#L211-L247","documentation":"Thrown by PojoTypeInfo.getFlatFields when a nested field expression (e.g. \"myField.subField\") references a field whose TypeInformation is atomic (not a CompositeType). You cannot drill into a scalar/basic type with a dot-separated tail. This is an InvalidFieldReferenceException.","triggerScenarios":"Calling keyBy(\"myString.length\") where myString is a String field (atomic), or keyBy(\"count.value\") where count is a primitive int/Integer. The matcher.group(3) returns a non-null tail but fieldType is not instanceof CompositeType.","commonSituations":"Developer assumes a field is a nested POJO or Tuple but the type extractor resolved it to a basic/atomic type. Common with boxed primitives, String fields, or when a nested class was not recognized as a POJO and fell back to a generic/atomic type.","solutions":["Remove the nested '.tail' from the key expression — reference the field directly.","If nesting is intended, verify the field's type is actually a CompositeType (POJO, Tuple, or Row) by printing its TypeInformation.","If the nested type was misclassified as generic/atomic, add proper POJO annotations or a public constructor/getter/setter to make it a recognized composite."],"exampleFix":"// before\nstream.keyBy(\"timestamp.millis\"); // timestamp is a long (atomic)\n// after\nstream.keyBy(\"timestamp\");","handlingStrategy":"validation","validationCode":"TypeInformation<?> fieldType =\n    ((CompositeType<?>) TypeInformation.of(MyPojo.class)).getTypeAt(fieldName);\nif (!(fieldType instanceof CompositeType)) {\n    throw new IllegalArgumentException(\n        \"Cannot nest into atomic field '\" + fieldName\n        + \"' of type \" + fieldType);\n}","typeGuard":"boolean isCompositeField(CompositeType<?> type, String field) {\n    return type.getTypeAt(field) instanceof CompositeType;\n}","tryCatchPattern":null,"preventionTips":["Before using dotted field expressions, verify the intermediate field is a CompositeType.","Inspect nested field types during development via TypeInformation."],"tags":["pojo","nested-field","atomic-type","type-system","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}