apache/iceberg · error · java.lang.IllegalArgumentException

Invalid iceberg type %s corresponding to Flink logical type

Error message

Invalid iceberg type %s corresponding to Flink logical type %s

What it means

Guard in FlinkOrcWriter.primitive: no Iceberg primitive type matches the Flink logical type of the column being written (the switch over Iceberg primitives found no case for this pairing). The message shows both the Iceberg type and the Flink logical type; it fires at writer construction time.

Source

Thrown at flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/data/FlinkOrcWriter.java:165

          }
        case TIMESTAMP_NANO:
          Types.TimestampNanoType timestampNanoType = (Types.TimestampNanoType) iPrimitive;
          if (timestampNanoType.shouldAdjustToUTC()) {
            return FlinkOrcWriters.timestampNanoTzs();
          } else {
            return FlinkOrcWriters.timestampNanos();
          }
        case STRING:
          return FlinkOrcWriters.strings();
        case UUID:
        case FIXED:
        case BINARY:
          return GenericOrcWriters.byteArrays();
        case DECIMAL:
          Types.DecimalType decimalType = (Types.DecimalType) iPrimitive;
          return FlinkOrcWriters.decimals(decimalType.precision(), decimalType.scale());
        default:
          throw new IllegalArgumentException(
              String.format(
                  "Invalid iceberg type %s corresponding to Flink logical type %s",
                  iPrimitive, flinkPrimitive));
      }
    }
  }
}

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Upgrade iceberg-flink to a version supporting the primitive type.
  2. Ensure the Flink schema passed to the writer matches the Iceberg table schema (same types, same order).
  3. Add a writer mapping for the missing primitive in a patched build if it's a legitimately new type.
Defensive patterns

Strategy: validation

Validate before calling

if (!WRITE_SUPPORTED.contains(primitive.typeId())) {
  throw new IllegalArgumentException("Cannot write " + primitive + " via ORC writer");
}

Try / catch

try { writer = FlinkOrcWriter.buildWriter(schema, flinkType); } catch (IllegalArgumentException e) { /* fail fast with schema mismatch */ }

Prevention

When it happens

Trigger: Writing a Flink RowData stream whose schema contains an Iceberg primitive the writer switch does not handle (e.g. new/unknown primitive or mismatched Iceberg-vs-Flink type pairs).

Common situations: Version skew between the connector and the table's schema types; constructing ORC writers from a Flink RowType that doesn't line up with the Iceberg schema.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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