apache/iceberg · error · UnsupportedOperationException

Unknown field ordinal

Error message

Unknown field ordinal: ${i}

What it means

CommitComplete is an Avro-record wrapper for the Kafka Connect commit event; its StructLike get(i) maps a field ordinal from the Avro schema to a field value (commitId or validThroughTs). If the ordinal doesn't match either known field, the code throws UnsupportedOperationException('Unknown field ordinal'). This means the Avro schema's field positions don't correspond to the expected event schema version.

Solutions

  1. Align producer and consumer on the same kafka-connect-events schema version (upgrade both to the same Iceberg release).
  2. Verify the topic/registry schema matches CommitComplete's Avro schema (COMMIT_ID, VALID_THROUGH_TS order).
  3. Ensure the event payload wasn't written by a different event class or an incompatible Iceberg version.
  4. If reading historical events from before the schema change, migrate or replay them with the old consumer version.

Example fix

// before
// consumer on iceberg 1.4 reading events produced by iceberg 1.5 schema
// after
// upgrade consumer dependency:
// implementation 'org.apache.iceberg:iceberg-kafka-connect-events:1.5.0'
Defensive patterns

Strategy: try-catch

Validate before calling

// verify producer/consumer schema agreement before deserializing
Schema writerSchema = avroData.getSchema(event);
if (writerSchema.getFields().size() != expectedCommitCompleteFields) {
  throw new IllegalStateException("CommitComplete schema version mismatch");
}

Try / catch

try {
  consumer.poll(...); // deserialize events
} catch (UnsupportedOperationException e) {
  if (e.getMessage().startsWith("Unknown field ordinal")) {
    log.error("Event schema version mismatch; upgrade iceberg-kafka-connect-events", e);
    // route to DLQ or replay with matching reader version
  } else throw e;
}

Prevention

When it happens

Trigger: Reading a CommitComplete event whose Avro schema has different field ordering/extra fields than the reader expects — e.g. a producer writing a newer or older schema version, or a corrupted/mismatched schema in the schema registry or topic.

Common situations: Rolling upgrades where old producers write pre-COMMIT_ID-field events and new consumers read them; mixing iceberg kafka-connect versions across producers/consumers; manual schema edits changing field order.

Related errors


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

Appendix: source

Thrown at kafka-connect/kafka-connect-events/src/main/java/org/apache/iceberg/connect/events/CommitComplete.java:112

        this.commitId = (UUID) v;
        return;
      case VALID_THROUGH_TS:
        this.validThroughTs = v == null ? null : DateTimeUtil.timestamptzFromMicros((Long) v);
        return;
      default:
        // ignore the object, it must be from a newer version of the format
    }
  }

  @Override
  public Object get(int i) {
    switch (AvroUtil.positionToId(i, avroSchema)) {
      case COMMIT_ID:
        return commitId;
      case VALID_THROUGH_TS:
        return validThroughTs == null ? null : DateTimeUtil.microsFromTimestamptz(validThroughTs);
      default:
        throw new UnsupportedOperationException("Unknown field ordinal: " + i);
    }
  }
}

View on GitHub (pinned to 86d9c8fc54)