apache/iceberg · error · 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

FlinkOrcWriter's PrimitiveWriterBuilder reached the default branch of its switch: the Iceberg primitive type has no mapping to an ORC writer for the given Flink logical type. The library throws IllegalArgumentException naming both the Iceberg primitive and the Flink logical type so the mismatch is visible. It signals an Iceberg type that the Flink ORC writer does not support.

Source

Thrown at flink/v2.2/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. Align the Flink RowType with the Iceberg table schema so every primitive has a supported mapping
  2. Check the Iceberg version's supported Flink-to-ORC type mappings and upgrade Iceberg if the type was added later
  3. Cast or transform unsupported columns to supported types (e.g. STRING, DECIMAL(<=38)) before writing

Example fix

// before (Flink schema has unsupported type mapping)
 DataTypes.DECIMAL(42, 5) // -> Iceberg DecimalType(42,5), no writer
// after
 DataTypes.DECIMAL(38, 5) // -> supported ORC decimal writer
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the Flink RowType matches the Iceberg schema before writing
List<Types.NestedField> columns = table.schema().columns();
for (Types.NestedField f : columns) {
  Preconditions.checkArgument(supportedMapping(f.type(), flinkRowType),
      "No ORC writer for %s", f.type());
}

Try / catch

try {
  writer = builder.primitive(iPrimitive, flinkPrimitive);
} catch (IllegalArgumentException e) {
  throw new SchemaMismatchException("Flink/Iceberg type mismatch: " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: Writing an Iceberg table via Flink where the row type's primitive is not one of the handled cases (e.g. an unexpected/iPrimitive combination reaching FlinkOrcWriter.Builder.primitive), such as writing a Flink type that maps to an Iceberg primitive with no ORC writer.

Common situations: Schema mismatch between the Flink RowType and the Iceberg schema (e.g. after an ALTER TABLE or a Flink connector upgrade), or custom TypeInformation producing an exotic Flink logical type, or a new Iceberg type added before the Flink ORC writer gained support.

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/2ae594038390c850. Report an issue: GitHub.