apache/flink · error · NumberFormatException
value overflow
Error message
value overflow
What it means
Thrown by LongParser.parseField when the parsed digit sequence overflows or underflows the 64-bit signed long range. The parser accumulates the value manually (val = val*10 + digit) and detects wrap-around only after val has already gone negative, so this fires when the accumulated value crossed Long.MAX_VALUE (or went below Long.MIN_VALUE for a negative number with extra digits).
Source
Thrown at flink-core/src/main/java/org/apache/flink/types/parser/LongParser.java:166
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.");
}
val *= 10;
val += bytes[startPos] - 48;
// check for overflow / underflow
if (val < 0) {
// this is an overflow/underflow, unless we hit exactly the Long.MIN_VALUE
if (neg && val == Long.MIN_VALUE) {
if (length == 1 || bytes[startPos + 1] == delimiter) {
return Long.MIN_VALUE;
} else {
throw new NumberFormatException("value overflow");
}
} else {
throw new NumberFormatException("value overflow");
}
}
}
return neg ? -val : val;
}
}
View on GitHub (pinned to 2f3c205e92)
Solutions
- Verify the field's true magnitude; if it can exceed 2^63-1, change the sink/target type to STRING or DECIMAL instead of LONG
- Check the delimiter configuration of the CSV reader (flink.connector.csv delimiter / field delimiter) so a single numeric field is not concatenated from multiple columns
- Sanitize or reject offending rows upstream (filter/validate the string length and digit-only content before parsing)
- If the value is actually within range, check for stray characters (e.g. a trailing digit after the Long.MIN_VALUE literal) that make an exact MIN_VALUE parse look like overflow
Example fix
// before
CsvReader csv = env.readFile(new RowCsvInputFormat(path, Types.LONG), path);
// after: widen the target type for oversized ids
RowCsvInputFormat fmt = new RowCsvInputFormat(path, Types.STRING, new boolean[]{true});
// then parse defensively:
long v;
try { v = Long.parseLong(s.trim()); } catch (NumberFormatException e) { v = /* handle */ 0L; } Defensive patterns
Strategy: validation
Validate before calling
boolean fitsLong(String s) {
String t = s.trim();
if (t.isEmpty() || !t.matches("-?\\d+")) return false;
String digits = t.startsWith("-") ? t.substring(1) : t;
if (digits.length() > 19) return false;
try { Long.parseLong(t); return true; }
catch (NumberFormatException e) { return false; }
} Try / catch
catch (NumberFormatException e) { log.warn("long overflow in field, routing to DLQ: {}", field); emitToDeadLetterQueue(row); } Prevention
- Declare BIGINT columns only for values verified to fit in 2^63-1
- Pre-scan file column max length; >19 digits means switch to STRING/DECIMAL
- Never let ids that may grow (snowflake, nanosecond timestamps) be typed LONG in text formats
When it happens
Trigger: Reading a text/CSV field with a RowCsvInputFormat or table source backed by these parsers where the numeric field exceeds 9223372036854775807 (e.g. '99999999999999999999'), or a negative field smaller than -9223372036854775808. Specifically this is the inner throw for the case neg && val == Long.MIN_VALUE but more digits or a non-delimiter byte follow the exact MIN_VALUE digit sequence.
Common situations: IDs (order ids, snowflake ids, timestamps in nanos) serialized as text and read into a LONG column; upstream producers switched from int to wider numeric ids; delimiter misconfiguration making the parser consume several fields as one long number; leading plus sign or scientific notation which the parser rejects as overflow/invalid.
Related errors
- Value overflow/underflow
- Value overflow/underflow
- Value overflow/underflow
- Empty field.
- Orphaned minus sign.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/e7833a7e8997c33d.
Report an issue: GitHub.