apache/flink · error · IllegalArgumentException

The type '{}' is not supported for the CSV input format.

Error message

The type '{}' is not supported for the CSV input format.

What it means

Thrown by GenericCsvInputFormat.setFieldTypesGeneric when a provided field type has no registered FieldParser. Flink's CSV parsing relies on a fixed table of FieldParser implementations (Byte, Short, Integer, Long, Float, Double, Boolean, String, BigDecimal, BigInteger, the *Value variants, and java.sql.Date/Time/Timestamp). Types outside this set — primitives, custom POJOs, arrays, List/Map, java.time types — cannot be parsed and are rejected.

Source

Thrown at flink-core/src/main/java/org/apache/flink/api/common/io/GenericCsvInputFormat.java:216

            return types;
        }
    }

    protected void setFieldTypesGeneric(Class<?>... fieldTypes) {
        if (fieldTypes == null) {
            throw new IllegalArgumentException("Field types must not be null.");
        }

        this.fieldIncluded = new boolean[fieldTypes.length];
        ArrayList<Class<?>> types = new ArrayList<Class<?>>();

        // check if we support parsers for these types
        for (int i = 0; i < fieldTypes.length; i++) {
            Class<?> type = fieldTypes[i];

            if (type != null) {
                if (FieldParser.getParserForType(type) == null) {
                    throw new IllegalArgumentException(
                            "The type '"
                                    + type.getName()
                                    + "' is not supported for the CSV input format.");
                }
                types.add(type);
                fieldIncluded[i] = true;
            }
        }

        this.fieldTypes = types.toArray(new Class<?>[types.size()]);
    }

    protected void setFieldsGeneric(int[] sourceFieldIndices, Class<?>[] fieldTypes) {
        checkNotNull(sourceFieldIndices);
        checkNotNull(fieldTypes);
        checkArgument(
                sourceFieldIndices.length == fieldTypes.length,
                "Number of field indices and field types must match.");

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Use the boxed wrapper types from the supported set: Integer.class, Long.class, Double.class, String.class, etc.
  2. For dates/times use java.sql.Date.class, java.sql.Time.class, java.sql.Timestamp.class (not java.time.*).
  3. For complex/POJO types, read the CSV into a Tuple of supported types and map to the POJO in a subsequent step.
  4. Prefer the modern Table API/SQL CSV connector, which supports a richer type system.

Example fix

// before
format.setFieldTypesGeneric(int.class, String.class, LocalDate.class);

// after
format.setFieldTypesGeneric(Integer.class, String.class, java.sql.Date.class);
Defensive patterns

Strategy: type-guard

Validate before calling

private static final Set<Class<?>> SUPPORTED = Set.of(
    Byte.class, Short.class, Integer.class, Long.class, Float.class,
    Double.class, Boolean.class, String.class, BigDecimal.class, BigInteger.class,
    java.sql.Date.class, java.sql.Time.class, java.sql.Timestamp.class);
for (Class<?> t : types) {
    if (t != null && !SUPPORTED.contains(t)) {
        throw new IllegalArgumentException("Unsupported CSV type: " + t);
    }
}

Type guard

static boolean isSupportedCsvType(Class<?> t) {
    return t == null || FieldParser.getParserForType(t) != null;
}

Prevention

When it happens

Trigger: Passing a primitive class such as int.class or long.class (the format expects the boxed wrappers); passing a custom POJO/record class; passing java.time.LocalDate/LocalDateTime; passing array or collection types.

Common situations: Using int.class instead of Integer.class; mapping CSV columns to a custom POJO directly instead of a tuple of supported types; migrating to java.time types without realizing only java.sql date/time are supported.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/e07188dea3bfc80e. Report an issue: GitHub.