apache/flink · error · NumberFormatException
Empty field.
Error message
Empty field.
What it means
Thrown by LongParser.parseField(byte[], int, int, char) when the first byte of the field equals the delimiter, i.e. an empty column. Like the other integer parsers it scans raw bytes and rejects empty long fields immediately with NumberFormatException rather than returning a default.
Source
Thrown at flink-core/src/main/java/org/apache/flink/types/parser/LongParser.java:137
/**
* Static utility to parse a field of type long 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 long 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 neg ? -val : val;
}
if (bytes[startPos] < 48 || bytes[startPos] > 57) {
throw new NumberFormatException("Invalid character.");
}View on GitHub (pinned to 2f3c205e92)
Solutions
- Populate or default the long column in the source data.
- Guard the call site: when the first byte is the delimiter, skip the record or substitute a default.
- Handle legitimately-missing values explicitly before invoking the strict parser.
Example fix
// before
long v = LongParser.parseField(bytes, start, len, '|');
// after
long v = (len > 0 && bytes[start] == (byte) '|')
? 0L
: LongParser.parseField(bytes, start, len, '|'); Defensive patterns
Strategy: validation
Validate before calling
if (len <= 0 || bytes[start] == (byte) delimiter) {
return 0L; // or flag record as invalid
} Try / catch
try {
long v = LongParser.parseField(bytes, start, len, delim);
} catch (NumberFormatException e) {
// empty/malformed long column: side output with row context
} Prevention
- Check the first byte against the delimiter before parsing.
- Define empty-cell handling for long columns explicitly.
- Validate delimiter configuration against the actual file format.
When it happens
Trigger: Calling LongParser.parseField(bytes, startPos, length, delimiter) where bytes[startPos] == (byte) delimiter — an empty long column between delimiters, e.g. "1||3" with '|'.
Common situations: Missing values in CSV exports rendered as empty cells; trailing delimiter creating an empty last field; column misalignment after schema changes.
Related errors
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/8eb08652b56d2775.
Report an issue: GitHub.