apache/iceberg · error · UnsupportedOperationException

Unknown field ordinal:

Error message

Unknown field ordinal: 

What it means

GenericPartitionFieldSummary.get supports ordinals 0-3 (containsNull, containsNaN, lowerBound, upperBound) and throws UnsupportedOperationException('Unknown field ordinal: ' + pos) otherwise. Like the other StructLike implementations, a foreign ordinal means the caller's positional access does not match the partition-field-summary struct schema.

Source

Thrown at core/src/main/java/org/apache/iceberg/GenericPartitionFieldSummary.java:162

  @Override
  public Object get(int i) {
    int pos = i;
    // if the schema was projected, map the incoming ordinal to the expected one
    if (fromProjectionPos != null) {
      pos = fromProjectionPos[i];
    }
    switch (pos) {
      case 0:
        return containsNull;
      case 1:
        return containsNaN;
      case 2:
        return lowerBound();
      case 3:
        return upperBound();
      default:
        throw new UnsupportedOperationException("Unknown field ordinal: " + pos);
    }
  }

  @Override
  @SuppressWarnings("unchecked")
  public <T> void set(int i, T value) {
    int pos = i;
    // if the schema was projected, map the incoming ordinal to the expected one
    if (fromProjectionPos != null) {
      pos = fromProjectionPos[i];
    }
    switch (pos) {
      case 0:
        this.containsNull = (Boolean) value;
        return;
      case 1:
        this.containsNaN = (Boolean) value;
        return;

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Access summary fields only through positions resolved from the summary struct type rather than hardcoded indices.
  2. Align the projection used for reading partition stats with the four supported summary fields.
  3. Upgrade Iceberg if the stats files contain a newer summary layout with additional fields.

Example fix

// before
Object v = summary.get(5);
// after
int pos = summaryType.fields().indexOf(summaryType.field("lower_bound"));
Object v = summary.get(pos);
Defensive patterns

Strategy: type-guard

Validate before calling

if (pos < 0 || pos > 3) throw new IllegalArgumentException("Summary ordinal out of range: " + pos);

Type guard

boolean isValidSummaryOrdinal(int pos) { return pos >= 0 && pos <= 3; }

Try / catch

try {
  Object v = summary.get(pos);
} catch (UnsupportedOperationException e) {
  if (e.getMessage().startsWith("Unknown field ordinal")) {
    // resolve the position from the summary struct type before accessing
  } else throw e;
}

Prevention

When it happens

Trigger: Calling get(pos) with pos outside 0..3, usually from a projection whose field count exceeds the summary struct (stale/foreign schema) or custom code hardcoding positions after schema changes.

Common situations: Partition statistics readers whose projected schema includes extra fields; version skew between writer and reader of partition stats files; hand-written positional accessors in analytics tooling.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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