apache/flink · error · IllegalArgumentException
Only simple types are supported in the second level nesting
Error message
Only simple types are supported in the second level nesting of fields '%s' but was: %s
What it means
Validation from the TypeInformation overload of CsvRowSchemaConverter.validateNestedField(): when converting an ARRAY or ROW field, each element type must itself be a simple number/string/boolean. If a nested element is itself complex (map, another row/array), conversion aborts with 'Only simple types are supported in the second level nesting' — CSV's Jackson schema has no representation for deeper structure.
Source
Thrown at flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvRowSchemaConverter.java:242
for (LogicalType fieldType : rowType.getChildren()) {
validateNestedField(fieldName, fieldType);
}
return CsvSchema.ColumnType.ARRAY;
} else {
throw new IllegalArgumentException(
"Unsupported type '"
+ type.asSummaryString()
+ "' for field '"
+ fieldName
+ "'.");
}
}
private static void validateNestedField(String fieldName, TypeInformation<?> info) {
if (!NUMBER_TYPES.contains(info)
&& !STRING_TYPES.contains(info)
&& !BOOLEAN_TYPES.contains(info)) {
throw new IllegalArgumentException(
"Only simple types are supported in the second level nesting of fields '"
+ fieldName
+ "' but was: "
+ info);
}
}
private static void validateNestedField(String fieldName, LogicalType type) {
if (!NUMBER_TYPE_ROOTS.contains(type.getTypeRoot())
&& !STRING_TYPE_ROOTS.contains(type.getTypeRoot())
&& !BOOLEAN_TYPE_ROOTS.contains(type.getTypeRoot())) {
throw new IllegalArgumentException(
"Only simple types are supported in the second level nesting of fields '"
+ fieldName
+ "' but was: "
+ type.asSummaryString());
}
}View on GitHub (pinned to 2f3c205e92)
Solutions
- Flatten nested rows inside arrays into delimited strings or separate columns before CSV writing.
- Move to a hierarchical format (json/avro/parquet) for such schemas.
- Restructure the row so arrays contain only scalars.
Defensive patterns
Strategy: type-guard
Validate before calling
// Check array/row elements before schema build:
void checkNested(String name, TypeInformation<?> el) {
if (!isCsvSimpleType(el)) throw new IllegalArgumentException(
"Nested field " + name + " too deep for CSV: " + el);
} Type guard
static boolean isCsvSimpleType(TypeInformation<?> info) {
return NUMBER_TYPES.contains(info) || STRING_TYPES.contains(info)
|| BOOLEAN_TYPES.contains(info);
} Prevention
- Keep arrays/rows to a single level of scalars for CSV
- Flatten line-item-style structures into strings or normalized streams
When it happens
Trigger: A RowTypeInfo containing BasicArrayTypeInfo<ObjectArrayTypeInfo<RowTypeInfo...>> or ObjectArrayTypeInfo<MapTypeInfo...>: arrays-of-rows or arrays-of-maps inside the row.
Common situations: Reusing rich event types (orders with line-item arrays that are themselves rows) for a CSV DataStream sink without flattening.
Related errors
- Unsupported type information '%s' for field '%s'.
- Unsupported type '%s' for field '%s'.
- Unsupported type: %s
- Csv does not support TIME type with precision: %s, it only s
- Serializing the source elements failed: {e.getMessage()}
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/8f7e9ca457f0e6f6.
Report an issue: GitHub.