apache/iceberg · error · java.lang.UnsupportedOperationException

Unsupported YearMonthIntervalType.

Error message

Unsupported YearMonthIntervalType.

What it means

FlinkTypeVisitor throws UnsupportedOperationException for YearMonthIntervalType because Iceberg has no corresponding interval type. Interval columns cannot be represented in an Iceberg schema, so conversion fails by design.

Solutions

  1. Replace the interval column with an integral type like INT (number of months) or BIGINT.
  2. Cast the interval to a numeric representation before writing to Iceberg.
  3. Subclass FlinkTypeVisitor and override visit(YearMonthIntervalType) with a custom mapping.
  4. Store as a string if the interval must be preserved verbatim.

Example fix

// before
col 'tenure' INTERVAL YEAR TO MONTH

// after
col 'tenure_months' INT
Defensive patterns

Strategy: validation

Validate before calling

for (Column col : resolvedSchema.getColumns()) {
  if (col.getDataType().getLogicalType() instanceof YearMonthIntervalType) {
    throw new IllegalArgumentException("Column '" + col.getName() + "' uses INTERVAL YEAR TO MONTH; use INT/BIGINT months");
  }
}

Try / catch

try {
  Schema s = FlinkSchemaUtil.toIcebergSchema(flinkSchema);
} catch (UnsupportedOperationException e) {
  if (e.getMessage().contains("YearMonthIntervalType")) {
    // replace interval columns with integer month counts
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Schema conversion (FlinkSchemaUtil.toIcebergSchema or similar) encountering a Flink column of type INTERVAL YEAR TO MONTH, dispatching to visit(YearMonthIntervalType).

Common situations: Tables carrying duration/tenure columns typed as INTERVAL YEAR TO MONTH; upstream systems (e.g. Oracle-style schemas) ported to Flink with native interval types.

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

Appendix: source

Thrown at flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/FlinkTypeVisitor.java:43

import org.apache.flink.table.types.logical.NullType;
import org.apache.flink.table.types.logical.RawType;
import org.apache.flink.table.types.logical.StructuredType;
import org.apache.flink.table.types.logical.SymbolType;
import org.apache.flink.table.types.logical.YearMonthIntervalType;
import org.apache.flink.table.types.logical.ZonedTimestampType;

public abstract class FlinkTypeVisitor<T> implements LogicalTypeVisitor<T> {

  // ------------------------- Unsupported types ------------------------------

  @Override
  public T visit(ZonedTimestampType zonedTimestampType) {
    throw new UnsupportedOperationException("Unsupported ZonedTimestampType.");
  }

  @Override
  public T visit(YearMonthIntervalType yearMonthIntervalType) {
    throw new UnsupportedOperationException("Unsupported YearMonthIntervalType.");
  }

  @Override
  public T visit(DayTimeIntervalType dayTimeIntervalType) {
    throw new UnsupportedOperationException("Unsupported DayTimeIntervalType.");
  }

  @Override
  public T visit(DistinctType distinctType) {
    throw new UnsupportedOperationException("Unsupported DistinctType.");
  }

  @Override
  public T visit(StructuredType structuredType) {
    throw new UnsupportedOperationException("Unsupported StructuredType.");
  }

  @Override

View on GitHub (pinned to 86d9c8fc54)