apache/iceberg · error

Field + name + not found in source schema

Error message

Field + name + not found in source schema

What it means

ReassignIds rewrites a type tree so field ids match a source schema. Its id(name) visitor callback looks up the field's id from the source schema and throws IllegalArgumentException when no field with that name exists. This means the schema being re-assigned contains a field absent from the reference schema.

Source

Thrown at api/src/main/java/org/apache/iceberg/types/ReassignIds.java:65

      return future.get();
    } finally {
      this.sourceType = null;
    }
  }

  private int id(Types.StructType sourceStruct, String name) {
    Types.NestedField sourceField =
        caseSensitive ? sourceStruct.field(name) : sourceStruct.caseInsensitiveField(name);

    if (sourceField != null) {
      return sourceField.fieldId();
    }

    if (assignId != null) {
      return assignId.get();
    }

    throw new IllegalArgumentException("Field " + name + " not found in source schema");
  }

  @Override
  public Type struct(Types.StructType struct, Iterable<Type> fieldTypes) {
    Preconditions.checkNotNull(sourceType, "Evaluation must start with a schema.");
    Preconditions.checkArgument(sourceType.isStructType(), "Not a struct: %s", sourceType);

    Types.StructType sourceStruct = sourceType.asStructType();
    List<Types.NestedField> fields = struct.fields();
    int length = fields.size();

    List<Type> types = Lists.newArrayList(fieldTypes);
    List<Types.NestedField> newFields = Lists.newArrayListWithExpectedSize(length);
    for (int i = 0; i < length; i += 1) {
      Types.NestedField field = fields.get(i);
      int fieldId = id(sourceStruct, field.name());
      newFields.add(Types.NestedField.from(field).withId(fieldId).ofType(types.get(i)).build());
    }

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Update the source schema to include all fields present in the type being re-assigned
  2. Rename/align field names so they match the source schema exactly
  3. Use reassignOrFreshIds if new fields should receive fresh ids instead of failing

Example fix

// before
Types.StructType t = TypeUtil.reassignIds(newType, oldSchema); // new field 'extra' missing in oldSchema
// after
Types.StructType t = TypeUtil.reassignOrFreshIds(newType, oldSchema::findField); // new fields get fresh ids
Defensive patterns

Strategy: validation

Validate before calling

for (Types.NestedField f : newType.asNestedType().fields()) {
  if (schema.findField(f.name()) == null) throw new IllegalArgumentException("Field missing in source schema: " + f.name());
}

Type guard

boolean assignable(Types.StructType t, Schema src) { return t.fields().stream().allMatch(f -> src.findField(f.name()) != null); }

Try / catch

try { t = TypeUtil.reassignIds(type, schema); } catch (IllegalArgumentException e) { t = TypeUtil.reassignOrFreshIds(type, schema::findField); }

Prevention

When it happens

Trigger: Calling TypeUtil.reassignIds(type, schema) (or the ReassignIds visitor via fieldId) where the incoming type has a field name not present in the source schema — e.g. schemas drifted or fields were renamed.

Common situations: Restoring ids on an evolved schema against a stale source schema; merging branches where one renamed a field; writing an Avro/Parquet file whose schema includes fields added after the reference snapshot.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/4028b9d2d5fe693d. Report an issue: GitHub.