{"record":{"id":"f24cd5ed97dc0ce9","repo":"apache/beam","slug":"unexpected-field-descriptor-type","errorCode":null,"errorMessage":"Unexpected field descriptor type.","messagePattern":"Unexpected field descriptor type\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/transforms/DropFields.java","lineNumber":117,"sourceCode":"            input.getNestedFieldsAccessed().keySet().stream()\n                .collect(Collectors.toMap(k -> k.getFieldId(), k -> k));\n\n        FieldAccessDescriptor.FieldDescriptor fieldDescriptor = nestedFields.get(i);\n        if (fieldDescriptor != null) {\n          // Some subfields are selected, so recursively calculate the complementary subfields to\n          // select.\n          FieldType fieldType = inputSchema.getField(i).getType();\n          for (FieldAccessDescriptor.FieldDescriptor.Qualifier qualifier :\n              fieldDescriptor.getQualifiers()) {\n            switch (qualifier.getKind()) {\n              case LIST:\n                fieldType = fieldType.getCollectionElementType();\n                break;\n              case MAP:\n                fieldType = fieldType.getMapValueType();\n                break;\n              default:\n                throw new RuntimeException(\"Unexpected field descriptor type.\");\n            }\n          }\n          checkArgument(fieldType.getTypeName().isCompositeType());\n          FieldAccessDescriptor nestedDescriptor =\n              input.getNestedFieldsAccessed().get(fieldDescriptor);\n          nestedFieldsToSelect.put(\n              fieldDescriptor, complement(fieldType.getRowSchema(), nestedDescriptor));\n        } else {\n          // Neither the field nor the subfield is selected. This means we should select it.\n          fieldNamesToSelect.add(field.getName());\n        }\n      }\n\n      FieldAccessDescriptor fieldAccess = FieldAccessDescriptor.withFieldNames(fieldNamesToSelect);\n      for (Map.Entry<FieldAccessDescriptor.FieldDescriptor, FieldAccessDescriptor> entry :\n          nestedFieldsToSelect.entrySet()) {\n        fieldAccess = fieldAccess.withNestedField(entry.getKey(), entry.getValue());\n      }","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/transforms/DropFields.java#L99-L135","documentation":"DropFields.complement walks nested field descriptors to compute the complement of the selected fields. While descending, the field type is expected to be a composite (ROW), ARRAY/LIST, or MAP; any other type name encountered while navigating a nested FieldAccessDescriptor is a bug in how the descriptor was constructed, so it throws RuntimeException.","triggerScenarios":"Passing a FieldAccessDescriptor with nested field accesses that descend through a field whose type is not ROW, ARRAY, or MAP at the level being navigated — e.g. referencing nested fields of a primitive-typed field.","commonSituations":"Typing a wrong field path in withFields/withoutFields (accessing .subfield on a non-composite column), or schema drift where a field changed from a row/array/map to a scalar between versions.","solutions":["Fix the field path so nested access only occurs on ROW/ARRAY/MAP typed fields.","Verify the input schema field types before building the FieldAccessDescriptor.","Check for schema drift: if the pipeline schema changed, update the DropFields paths.","If it appears with a valid descriptor, file a Beam bug — this indicates an internal inconsistency in descriptor resolution."],"exampleFix":"// before\n.withFields(\"scalarField.nested\") // scalarField is INT64\n// after\n.withFields(\"rowField.nested\")","handlingStrategy":"validation","validationCode":"Schema.FieldType t = schema.getField(path[0]).getType(); if (!(t.getTypeName().isCompositeType() || t.getTypeName().equals(TypeName.ARRAY) || t.getTypeName().equals(TypeName.MAP))) throw new IllegalArgumentException(\"Cannot descend into non-composite field\");","typeGuard":null,"tryCatchPattern":"try { result = input.apply(DropFields.withoutFields(desc)); } catch (RuntimeException e) { if (e.getMessage().equals(\"Unexpected field descriptor type.\")) { /* fix descriptor paths */ } throw e; }","preventionTips":["Validate field paths against the actual schema in tests","Watch for schema drift between pipeline versions","Only build nested FieldAccessDescriptors on ROW/ARRAY/MAP fields"],"tags":["java","apache-beam","drop-fields","field-descriptor"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}