apache/flink · error · NumberFormatException
Empty field.
Error message
Empty field.
What it means
Thrown by IntParser.parseField(byte[], int, int, char) when the field starts with the delimiter byte, i.e. the column is empty. The static parser scans raw bytes and rejects an empty column immediately with NumberFormatException instead of producing a default value.
Source
Thrown at flink-core/src/main/java/org/apache/flink/types/parser/IntParser.java:129
/**
* Static utility to parse a field of type int from a byte sequence that represents text
* characters (such as when read from a file stream).
*
* @param bytes The bytes containing the text data that should be parsed.
* @param startPos The offset to start the parsing.
* @param length The length of the byte sequence (counting from the offset).
* @param delimiter The delimiter that terminates the field.
* @return The parsed value.
* @throws NumberFormatException Thrown when the value cannot be parsed because the text
* represents not a correct number.
*/
public static final int parseField(byte[] bytes, int startPos, int length, char delimiter) {
long val = 0;
boolean neg = false;
if (bytes[startPos] == delimiter) {
throw new NumberFormatException("Empty field.");
}
if (bytes[startPos] == '-') {
neg = true;
startPos++;
length--;
if (length == 0 || bytes[startPos] == delimiter) {
throw new NumberFormatException("Orphaned minus sign.");
}
}
for (; length > 0; startPos++, length--) {
if (bytes[startPos] == delimiter) {
return (int) (neg ? -val : val);
}
if (bytes[startPos] < 48 || bytes[startPos] > 57) {
throw new NumberFormatException("Invalid character.");
}View on GitHub (pinned to 2f3c205e92)
Solutions
- Fix source data or delimiter handling so int columns are populated.
- Guard the call: skip the record or substitute a default when the first byte equals the delimiter.
- If empty cells are valid, map them explicitly (e.g. to null via a nullable wrapper) rather than calling the strict parser.
Example fix
// before
int v = IntParser.parseField(bytes, start, len, ',');
// after
int v = (len > 0 && bytes[start] == (byte) ',')
? 0
: IntParser.parseField(bytes, start, len, ','); Defensive patterns
Strategy: validation
Validate before calling
if (len <= 0 || bytes[start] == (byte) delimiter) {
return 0; // or flag record as invalid
} Try / catch
try {
int v = IntParser.parseField(bytes, start, len, delim);
} catch (NumberFormatException e) {
// empty/malformed int column: side output with row context
} Prevention
- Check the first byte against the delimiter before parsing.
- Define empty-cell policy for int columns up front.
- Validate column counts per row to catch schema drift early.
When it happens
Trigger: Calling IntParser.parseField(bytes, startPos, length, delimiter) where bytes[startPos] == (byte) delimiter — e.g. "7,,9" with ',' delimiter: the middle empty int column throws.
Common situations: CSV rows with missing numeric cells (consecutive delimiters), trailing delimiter yielding an empty last field, or column misalignment after the header schema changes.
Related errors
- Invalid input: Empty string
- Empty field.
- Orphaned minus sign.
- Invalid character.
- Value overflow/underflow
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/b66c59d9578dddd8.
Report an issue: GitHub.