apache/iceberg · error · UnsupportedOperationException

Unsupported type: interval

Error message

Unsupported type: interval

What it means

StructInternalRow does not implement support for Spark's CalendarInterval type; getInterval unconditionally throws UnsupportedOperationException. Iceberg tables have no interval type, so intervals are simply not representable in an Iceberg row.

Solutions

  1. Avoid selecting interval-typed expressions directly from Iceberg rows; cast them to a supported type (e.g. string or long months/days)
  2. Compute intervals outside the Iceberg scan projection
  3. If in Spark code, materialize the interval after converting to Spark's own row representation

Example fix

// before
SELECT INTERVAL '1' DAY AS i FROM iceberg_table
// after
SELECT CAST(INTERVAL '1' DAY AS STRING) AS i FROM iceberg_table
Defensive patterns

Strategy: validation

Validate before calling

for (StructField f : schema.fields()) {
  if (f.dataType() instanceof CalendarIntervalType) {
    throw new IllegalArgumentException("Interval columns are not supported by Iceberg rows");
  }
}

Type guard

static boolean isInterval(DataType t) {
  return t instanceof CalendarIntervalType;
}

Try / catch

try {
  row.getInterval(i);
} catch (UnsupportedOperationException e) {
  value = computeIntervalExternally(i);
}

Prevention

When it happens

Trigger: Calling getInterval(ordinal) on a StructInternalRow, typically when Spark's vectorized/row reader framework attempts to decode an interval column against an Iceberg-backed row.

Common situations: Queries or datasets containing SQL interval expressions materialized through IcebergInternalRow wrappers; framework code calling all InternalRow accessors generically.

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/735fa8bb9d520635. Report an issue: GitHub.

Appendix: source

Thrown at spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/source/StructInternalRow.java:219

      return ByteBuffers.toByteArray((ByteBuffer) bytes);
    } else if (bytes instanceof byte[]) {
      return (byte[]) bytes;
    } else {
      throw new IllegalStateException(
          "Unknown type for binary field. Type name: " + bytes.getClass().getName());
    }
  }

  @Override
  public BinaryView getBinaryView(int ordinal) {
    return isNullAt(ordinal)
        ? null
        : toBinaryView(type.fields().get(ordinal).type(), getBinaryInternal(ordinal));
  }

  @Override
  public CalendarInterval getInterval(int ordinal) {
    throw new UnsupportedOperationException("Unsupported type: interval");
  }

  @Override
  public InternalRow getStruct(int ordinal, int numFields) {
    return isNullAt(ordinal) ? null : getStructInternal(ordinal);
  }

  private InternalRow getStructInternal(int ordinal) {
    return new StructInternalRow(
        type.fields().get(ordinal).type().asStructType(), struct.get(ordinal, StructLike.class));
  }

  @Override
  public ArrayData getArray(int ordinal) {
    return isNullAt(ordinal) ? null : getArrayInternal(ordinal);
  }

  private ArrayData getArrayInternal(int ordinal) {

View on GitHub (pinned to 86d9c8fc54)