apache/druid · error · ParseException
Could not convert value [%s] to long.
Error message
Could not convert value [%s] to long.
What it means
DimensionHandlerUtils.convertObjectToLong converts an ingested field value to a long. When the value is a String that cannot be parsed as a long (Long.parseLong fails), Druid throws a ParseException with this message. It indicates the input data does not match the declared long column type.
Source
Thrown at processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java:405
} else if (valObj instanceof Boolean) {
return Evals.asLong((Boolean) valObj);
} else if (valObj instanceof String) {
Long ret = DimensionHandlerUtils.getExactLongFromDecimalString((String) valObj);
if (reportParseExceptions && ret == null) {
final String message;
if (objectKey != null) {
message = StringUtils.nonStrictFormat(
"Could not convert value [%s] to long for dimension [%s].",
valObj,
objectKey
);
} else {
message = StringUtils.nonStrictFormat(
"Could not convert value [%s] to long.",
valObj
);
}
throw new ParseException((String) valObj, message);
}
return ret;
} else if (valObj instanceof List) {
final String message;
if (objectKey != null) {
message = StringUtils.nonStrictFormat(
"Could not ingest value [%s] as long for dimension [%s]. A long column cannot have multiple values in the same row.",
valObj,
objectKey
);
} else {
message = StringUtils.nonStrictFormat(
"Could not ingest value [%s] as long. A long column cannot have multiple values in the same row.",
valObj
);
}
throw new ParseException(
valObj.getClass().toString(),View on GitHub (pinned to 9b90983fd2)
Solutions
- Fix the input data so the value is an integer-parseable string (e.g. "1" not "1.0"), or drop/transform bad values.
- Use an ingest-time transform or parse expression (e.g. REGEXP_EXTRACT, CAST) to normalize values before the long conversion.
- Change the column type to string or double in the ingestion spec if values genuinely aren't integers.
- Handle ParseException in your ingestion error handler / tune maxParseExceptions so the job doesn't halt unexpectedly.
Example fix
// before: ingesting "1.5" into a long column
// after: add a transform to round/parse safely
"transforms": [{"type": "expression", "name": "myLongCol", "expression": "CAST(CAST(myCol AS DOUBLE) AS LONG)"}] Defensive patterns
Strategy: try-catch
Validate before calling
boolean isParsableLong(Object v) {
if (v == null) return true;
if (v instanceof Number) return true;
if (v instanceof String) {
try { Long.parseLong((String) v); return true; } catch (NumberFormatException e) { return false; }
}
return false;
} Type guard
Long asLong(Object v) {
if (v instanceof Number) return ((Number) v).longValue();
if (v instanceof String) { try { return Long.parseLong((String) v); } catch (NumberFormatException e) { return null; } }
return null;
} Try / catch
try {
return DimensionHandlerUtils.convertObjectToLong(value, fieldName, objectKey);
} catch (ParseException e) {
log.warn("Skipping non-long value [%s] for field [%s]", value, fieldName);
return null; // or route row to a dead-letter channel
} Prevention
- Pre-validate numeric fields against a regex like ^-?\d+$ before ingest
- Use ingest transforms to CAST/normalize values
- Sample input data when building the ingestion spec to confirm types
- Set maxParseExceptions and monitor rejected rows
When it happens
Trigger: Ingesting a row where a dimension/column declared as long receives a string like "abc" or "12.5" that Long.parseLong cannot parse; convertObjectToLong called on a non-numeric string value.
Common situations: Input format mismatch (e.g. CSV field "1,000" or "1.0" mapped to a long column); ETL producing locale-formatted numbers; schema drift where a column was re-declared as long but data still contains text.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Could not convert value [%s] to float.
- Could not convert value [%s] to double.
- Could not ingest value [%s] as long for dimension [%s]. A lo
- Could not convert value [%s] to long for dimension [%s]. Inv
- Could not ingest value [%s] as float for dimension [%s]. A f
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/d6b9f040a917d239.
Report an issue: GitHub.