apache/flink · error · RuntimeException

No parser available for type

Error message

No parser available for type '{}'.

What it means

Thrown inside GenericCsvInputFormat.initializeSplit when FieldParser.getParserForType(fieldTypes[i]) returns null, meaning the configured field type has no registered CSV parser. Flink's CSV readers only support a fixed set of primitive/wrapper types (Byte, Short, Integer, Long, Float, Double, Boolean, String, BigDecimal, BigInteger, java.sql.Date, java.sql.Time, java.sql.Timestamp). This is a defensive runtime re-check; the same condition is normally caught earlier in setFieldTypesGeneric / setFieldsGeneric with an IllegalArgumentException, so reaching this RuntimeException means fieldTypes was populated without going through the validating setters.

Solutions

  1. Restrict each configured field type to one of the supported parsers: Byte/byte, Short/short, Integer/int, Long/long, Float/float, Double/double, Boolean/boolean, String, BigDecimal, BigInteger, java.sql.Date, java.sql.Time, java.sql.Timestamp.
  2. If you need a richer type, declare the field as String and convert it yourself in the map/function following the source.
  3. Route field type setup through the validated setters (setFieldTypesGeneric / setFieldsGeneric) so an IllegalArgumentException is raised at job-construction time with a clearer message instead of at runtime on the cluster.
  4. Check the unsupported type by calling FieldParser.getParserForType(type) in a unit test before submitting the job.

Example fix

// before
format.setFieldTypesGeneric(MyPojo.class, Integer.class);
// after
format.setFieldTypesGeneric(String.class, Integer.class);
// then map MyPojo from the String field yourself
Defensive patterns

Strategy: validation

Validate before calling

import org.apache.flink.types.parser.FieldParser;

private static void assertAllTypesParsable(Class<?>... fieldTypes) {
    for (Class<?> t : fieldTypes) {
        if (t != null && FieldParser.getParserForType(t) == null) {
            throw new IllegalArgumentException(
                "No CSV parser for type " + t.getName()
                + ". Supported: primitives/wrappers, String, BigDecimal, BigInteger,"
                + " java.sql.Date/Time/Timestamp.");
        }
    }
}
// call in a unit test or job setup before opening the format

Type guard

// Restrict the field-type vocabulary at the API boundary
static final Set<Class<?>> CSV_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);

static Class<?> csvType(Class<?> t) {
    if (!CSV_SUPPORTED.contains(t)) throw new IllegalArgumentException("Unsupported CSV type: " + t);
    return t;
}

Try / catch

// Wrap format open in a try and surface a clear configuration error
try {
    format.open(split);
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("No parser available for type")) {
        throw new IllegalArgumentException(
            "A configured CSV field type has no parser. Use a supported type.", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: A subclass of GenericCsvInputFormat (or RowCsvInputFormat) assigns this.fieldTypes directly (or via a custom path) with an unsupported Class such as a POJO, Tuple, Map, List, java.util.Date, java.time.LocalDate, or an enum. Then JobManager/TaskManager opens the split and initializeSplit runs getParserForType which returns null.

Common situations: Switching from java.util.Date to java.time types after a Java 8 migration; passing a custom value class thinking the CSV reader will call a constructor/fromString method; using a Tuple type field instead of its component types; upgrading Flink where a previously-tolerated type is no longer auto-converted; copy-pasting a Class<?> array from a different reader.

Related errors


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

Appendix: source

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

    }

    // --------------------------------------------------------------------------------------------
    //  Runtime methods
    // --------------------------------------------------------------------------------------------

    @Override
    protected void initializeSplit(FileInputSplit split, Long offset) throws IOException {
        super.initializeSplit(split, offset);

        // instantiate the parsers
        FieldParser<?>[] parsers = new FieldParser<?>[fieldTypes.length];

        for (int i = 0; i < fieldTypes.length; i++) {
            if (fieldTypes[i] != null) {
                Class<? extends FieldParser<?>> parserType =
                        FieldParser.getParserForType(fieldTypes[i]);
                if (parserType == null) {
                    throw new RuntimeException(
                            "No parser available for type '" + fieldTypes[i].getName() + "'.");
                }

                FieldParser<?> p = InstantiationUtil.instantiate(parserType, FieldParser.class);

                p.setCharset(getCharset());
                if (this.quotedStringParsing) {
                    if (p instanceof StringParser) {
                        ((StringParser) p).enableQuotedStringParsing(this.quoteCharacter);
                    } else if (p instanceof StringValueParser) {
                        ((StringValueParser) p).enableQuotedStringParsing(this.quoteCharacter);
                    }
                }

                parsers[i] = p;
            }
        }
        this.fieldParsers = parsers;

View on GitHub (pinned to 2f3c205e92)