apache/iceberg · error · java.lang.UnsupportedOperationException

Unsupported YearMonthIntervalType.

Error message

Unsupported YearMonthIntervalType.

What it means

Flink's YearMonthIntervalType (INTERVAL YEAR/MONTH) has no mapping to an Iceberg type, so FlinkTypeVisitor deliberately throws UnsupportedOperationException when a type conversion visitor reaches it. Iceberg's schema model has no YEAR/MONTH interval type, so conversion of a table containing this column cannot proceed.

Source

Thrown at flink/v1.20/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)

Solutions

  1. Remove the YearMonthIntervalType column from the schema or cast it to a supported type (BIGINT month count or STRING) before writing to Iceberg.
  2. Cast the interval to its numeric representation in SQL, e.g. CAST(interval_col AS BIGINT) or EXTRACT(MONTH ...).
  3. Store start/end timestamps in Iceberg and derive the interval at query time instead.
  4. If you own the FlinkTypeVisitor subclass, override visit(YearMonthIntervalType) with a custom mapping.

Example fix

// before: table with interval column
CREATE TABLE t (i INTERVAL YEAR TO MONTH, ...) WITH ('connector'='iceberg');
// after: cast to a supported Iceberg type
CREATE TABLE t (i BIGINT, ...) WITH ('connector'='iceberg');
INSERT INTO t SELECT CAST(i AS BIGINT) FROM staged;
Defensive patterns

Strategy: validation

Validate before calling

import org.apache.flink.table.types.logical.LogicalType;
import org.apache.flink.table.types.logical.YearMonthIntervalType;

static void assertIcebergCompatible(org.apache.flink.table.api.Schema schema) {
  schema.getColumns().forEach(c -> {
    LogicalType t = c.getType().getLogicalType();
    if (t instanceof YearMonthIntervalType) {
      throw new IllegalArgumentException(
          "Column type " + c + " (INTERVAL YEAR/MONTH) is not supported by Iceberg; cast to BIGINT or STRING first.");
    }
  });
}

Type guard

static boolean isUnsupportedByIceberg(LogicalType t) {
  return t instanceof YearMonthIntervalType || t instanceof DayTimeIntervalType;
}

Prevention

When it happens

Trigger: Calling FlinkSchemaUtil.convert() or other FlinkTypeVisitor-based conversion (FlinkCatalog, sink/source schema resolution) on a row type containing a column declared as INTERVAL YEAR, INTERVAL YEAR TO MONTH, or INTERVAL MONTH.

Common situations: Defining a Flink Table API or SQL table with an interval-typed column (e.g. a date difference returning a YEAR/MONTH interval) then writing to Iceberg; introducing interval types via computed columns; assuming Iceberg supports interval types like it supports timestamps.

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