apache/iceberg · error · java.lang.UnsupportedOperationException

Unsupported YearMonthIntervalType.

Error message

Unsupported YearMonthIntervalType.

What it means

FlinkTypeVisitor's default visit(YearMonthIntervalType) throws UnsupportedOperationException because Flink's INTERVAL YEAR/MONTH types have no Iceberg counterpart. Encountering such a column in a type conversion aborts with this error.

Solutions

  1. Cast the interval column to a supported type, e.g. store as BIGINT months or STRING.
  2. Compute the interval at read time from DATE/TIMESTAMP columns instead of persisting it.
  3. Override visit(YearMonthIntervalType) in a custom visitor with an explicit mapping.

Example fix

// before
CREATE TABLE t (dur INTERVAL YEAR TO MONTH) -- iceberg sink
// after
CREATE TABLE t (dur_months BIGINT) -- CAST/duration_in_months
Defensive patterns

Strategy: validation

Validate before calling

schema.getColumns().forEach(c -> {
  if (c.getDataType().getLogicalType() instanceof YearMonthIntervalType) {
    throw new IllegalArgumentException("Interval YEAR/MONTH not supported by Iceberg: " + c.getName());
  }
});

Type guard

boolean isYearMonthInterval(LogicalType t) { return t instanceof YearMonthIntervalType; }

Try / catch

try {
  RowType rowType = FlinkSchemaUtil.toType(rowDataType);
} catch (UnsupportedOperationException e) {
  // find interval columns and recast to BIGINT/STRING
}

Prevention

When it happens

Trigger: Flink-to-Iceberg conversion (FlinkSchemaUtil.toType/fromFlinkSchema) on a schema containing an INTERVAL YEAR, INTERVAL YEAR TO MONTH, or INTERVAL MONTH column.

Common situations: Schemas produced by date-diff computations typed as year-month intervals being written to an Iceberg sink; porting SQL from engines that map such intervals to storage types.

Related errors


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

Appendix: source

Thrown at flink/v2.1/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)