apache/druid · error · ParseException

Could not convert value [%s] to double.

Error message

Could not convert value [%s] to double.

What it means

DimensionHandlerUtils.convertObjectToDouble converts values to double; when a String cannot be parsed as a double (Double.parseDouble fails), this ParseException is thrown. It indicates non-numeric text in a double column.

Source

Thrown at processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java:725

    } else if (valObj instanceof Number) {
      return ((Number) valObj).doubleValue();
    } else if (valObj instanceof String) {
      Double ret = Doubles.tryParse((String) valObj);
      if (reportParseExceptions && ret == null) {
        final String message;
        if (fieldName != null) {
          message = StringUtils.nonStrictFormat(
              "Could not convert value [%s] to double for dimension [%s].",
              valObj,
              fieldName
          );
        } else {
          message = StringUtils.nonStrictFormat(
              "Could not convert value [%s] to double.",
              valObj
          );
        }
        throw new ParseException((String) valObj, message);
      }
      return ret;
    } else if (valObj instanceof List) {
      final String message;
      if (fieldName != null) {
        message = StringUtils.nonStrictFormat(
            "Could not ingest value [%s] as double for dimension [%s]. A double column cannot have multiple values in the same row.",
            valObj,
            fieldName
        );
      } else {
        message = StringUtils.nonStrictFormat(
            "Could not ingest value [%s] as double. A double column cannot have multiple values in the same row.",
            valObj
        );
      }

      throw new ParseException(

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Sanitize input with a transform (map "N/A"/"-" to null or 0 before CAST).
  2. Fix upstream producers to emit valid doubles or explicit nulls.
  3. Change the column to string type if values are not consistently numeric.
  4. Increase maxParseExceptions or route errors to a handler to avoid job failure on isolated bad rows.

Example fix

// before: value "N/A" fails Double.parseDouble
// after: transform maps sentinels to null
"transforms": [{"type": "expression", "name": "amount", "expression": "case when amount in ('N/A','-','') then null else CAST(amount AS DOUBLE) end"}]
Defensive patterns

Strategy: try-catch

Validate before calling

boolean isParsableDouble(Object v) {
  if (v == null) return true;
  if (v instanceof Number) return true;
  if (v instanceof String) {
    String s = ((String) v).trim();
    if (s.isEmpty() || s.equalsIgnoreCase("n/a") || s.equals("-")) return false;
    try { Double.parseDouble(s); return true; } catch (NumberFormatException e) { return false; }
  }
  return false;
}

Type guard

Double asDouble(Object v) {
  if (v instanceof Number) return ((Number) v).doubleValue();
  if (v instanceof String) { try { return Double.parseDouble((String) v); } catch (NumberFormatException e) { return null; } }
  return null;
}

Try / catch

try {
  return DimensionHandlerUtils.convertObjectToDouble(value, fieldName);
} catch (ParseException e) {
  log.warn("Non-double value [%s] for field [%s], defaulting to null", value, fieldName);
  return null;
}

Prevention

When it happens

Trigger: Ingesting values like "N/A", "", or "12.3.4" into a double-typed column; convertObjectToDouble invoked on unparseable strings; also dispatched from convertObjectToType.

Common situations: Placeholder strings ("null", "N/A", "-") in numeric fields; locale-formatted decimals; corrupted CSV rows.

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


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/e65866a0322a26e4. Report an issue: GitHub.