apache/druid · error · ParseException

Could not convert value [%s] to double for dimension [%s]. I

Error message

Could not convert value [%s] to double for dimension [%s]. Invalid type: [%s]

What it means

Druid's convertObjectToDouble coerces an ingested/queried dimension value into a double. This ParseException is thrown when the value is neither a Number nor a String parseable as a double (e.g. a complex object or nested structure), so Druid cannot represent it in a DOUBLE-typed column. It is thrown eagerly during ingestion/segment conversion rather than silently nulling the value.

Source

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

          valObj.getClass().toString(),
          message
      );
    } else {
      final String message;
      if (fieldName != null) {
        message = StringUtils.nonStrictFormat(
            "Could not convert value [%s] to double for dimension [%s]. Invalid type: [%s]",
            valObj,
            fieldName,
            valObj.getClass()
        );
      } else {
        message = StringUtils.nonStrictFormat(
            "Could not convert value [%s] to double. Invalid type: [%s]",
            valObj, valObj.getClass()
        );
      }
      throw new ParseException(
          valObj.getClass().toString(),
          message
      );
    }
  }

  /**
   * Convert a string representing a decimal value to a long.
   * <p>
   * If the decimal value is not an exact integral value (e.g. 42.0), or if the decimal value
   * is too large to be contained within a long, this function returns null.
   *
   * @param decimalStr string representing a decimal value
   * @return long equivalent of decimalStr, returns null for non-integral decimals and integral decimal values outside
   * of the values representable by longs
   */
  @Nullable
  public static Long getExactLongFromDecimalString(String decimalStr)

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Fix the input so the field is a plain number or numeric string for rows feeding DOUBLE dimensions (add a flatten/transform spec or reject bad records upstream).
  2. Check the 'Invalid type' in the message to see which class leaked in and adjust the parser/flattenSpec so that type never reaches the column.
  3. If multi-value values are the issue, use the related multi-value error path — a double column cannot hold lists; aggregate or extract a scalar first.
  4. Handle ParseException at the ingestion call site and route the row to a dead-letter/parse-exception handling config instead of failing the whole task.

Example fix

// before: passing raw JSON field that may be an object
Double v = DimensionHandlerUtils.convertObjectToDouble(row.getRaw(field), field);
// after: guard and coerce only scalar numerics/strings
Object raw = row.getRaw(field);
Double v = (raw instanceof Number || raw instanceof String)
    ? DimensionHandlerUtils.convertObjectToDouble(raw, field)
    : null; // or log/skip the row
Defensive patterns

Strategy: validation

Validate before calling

static boolean isDoubleConvertible(Object v) {
  return v instanceof Number || (v instanceof String && isNumeric((String) v));
}
private static boolean isNumeric(String s) {
  try { Double.parseDouble(s); return true; } catch (NumberFormatException e) { return false; }
}

Type guard

if (!(val instanceof Number) && !(val instanceof String)) {
  throw new IllegalArgumentException("Expected numeric or numeric string, got: " + val.getClass());
}

Try / catch

try {
  Double d = DimensionHandlerUtils.convertObjectToDouble(valObj, fieldName);
} catch (ParseException pe) {
  log.warn("Unparseable double for dimension [%s]: %s", fieldName, pe.getMessage());
  // route to reject/dead-letter path instead of failing the batch
}

Prevention

When it happens

Trigger: Calling DimensionHandlerUtils.convertObjectToDouble with a value whose runtime type is not Number/String/List — e.g. a Map, nested object from JSON input, or a custom serializer output — destined for a dimension declared as DOUBLE.

Common situations: Ingesting JSON records where a numeric column occasionally contains a nested object or array; schema drift in Kafka/Kinesis streams; a flattenExpr or transform producing objects for a DOUBLE metric column; passing typed QueryableIndex values of unexpected type through convertObjectToType.

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/5bb1fb7b7fcf013e. Report an issue: GitHub.