apache/iceberg · error · java.lang.UnsupportedOperationException

Unsupported DistinctType.

Error message

Unsupported DistinctType.

What it means

FlinkTypeVisitor throws UnsupportedOperationException for DistinctType, Flink's user-defined distinct structured type. Iceberg's type system has no equivalent, so the default visitor rejects it during schema conversion.

Solutions

  1. Replace the distinct type with its underlying base type (e.g. the wrapped VARCHAR/INT) in the schema.
  2. Cast the column to the underlying base type before conversion.
  3. Subclass FlinkTypeVisitor and override visit(DistinctType) to delegate to the source type's conversion.
  4. Avoid using Flink DISTINCT types in Iceberg-backed tables.

Example fix

// before
CREATE DISTINCT TYPE email AS VARCHAR(320);
col 'contact' email

// after
col 'contact' VARCHAR(320)
Defensive patterns

Strategy: validation

Validate before calling

for (Column col : resolvedSchema.getColumns()) {
  if (col.getDataType().getLogicalType() instanceof DistinctType) {
    throw new IllegalArgumentException("Column '" + col.getName() + "' uses a Flink DISTINCT type; use the base type");
  }
}

Try / catch

try {
  Schema s = FlinkSchemaUtil.toIcebergSchema(flinkSchema);
} catch (UnsupportedOperationException e) {
  if (e.getMessage().contains("DistinctType")) {
    // replace distinct types with their base types
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Schema conversion encountering a Flink catalog column whose DataType resolves to a DistinctType (user-defined distinct type), dispatching to visit(DistinctType).

Common situations: Flink Catalog tables defined with user-defined DISTINCT types (e.g. CREATE DISTINCT TYPE); using a custom Flink catalog that resolves columns to distinct 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/91c9a8ac98614b75. Report an issue: GitHub.

Appendix: source

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

  @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
  public T visit(NullType nullType) {
    throw new UnsupportedOperationException("Unsupported NullType.");
  }

  @Override
  public T visit(RawType<?> rawType) {
    throw new UnsupportedOperationException("Unsupported RawType.");
  }

  @Override

View on GitHub (pinned to 86d9c8fc54)