apache/iceberg · error · UnsupportedOperationException

Unsupported YearMonthIntervalType.

Error message

Unsupported YearMonthIntervalType.

What it means

FlinkTypeVisitor.visit(YearMonthIntervalType) throws UnsupportedOperationException because Iceberg has no interval type; Flink's INTERVAL YEAR TO MONTH columns cannot be represented in an Iceberg schema.

Solutions

  1. Store the interval as a numeric or string column (e.g. total months as INT) in the Flink DDL.
  2. Convert the interval to a duration/number of months before writing to Iceberg.
  3. Override visit(YearMonthIntervalType) in a custom visitor if a project-specific encoding is required.

Example fix

// before
column <INTERVAL YEAR TO MONTH> ivl;
// after
column INT months_between; // populate via computed months value
Defensive patterns

Strategy: type-guard

Validate before calling

if (dataType.getLogicalType() instanceof YearMonthIntervalType) {
  throw new IllegalArgumentException("Convert INTERVAL YEAR TO MONTH to INT months before Iceberg write");
}

Prevention

When it happens

Trigger: Schema conversion (FlinkTypeUtil.toIcebergType / FlinkSchemaUtil) over a Flink schema containing `INTERVAL YEAR TO MONTH` columns.

Common situations: Pipelines that read interval columns from relational sources (e.g. Oracle/Postgres date arithmetic results) and try to write them straight into Iceberg tables.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


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

Appendix: source

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