{"record":{"id":"5bb1fb7b7fcf013e","repo":"apache/druid","slug":"could-not-convert-value-s-to-double-for-dimensi","errorCode":null,"errorMessage":"Could not convert value [%s] to double for dimension [%s]. Invalid type: [%s]","messagePattern":"Could not convert value \\[(.+?)\\] to double for dimension \\[(.+?)\\]\\. Invalid type: \\[(.+?)\\]","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java","lineNumber":762,"sourceCode":"          valObj.getClass().toString(),\n          message\n      );\n    } else {\n      final String message;\n      if (fieldName != null) {\n        message = StringUtils.nonStrictFormat(\n            \"Could not convert value [%s] to double for dimension [%s]. Invalid type: [%s]\",\n            valObj,\n            fieldName,\n            valObj.getClass()\n        );\n      } else {\n        message = StringUtils.nonStrictFormat(\n            \"Could not convert value [%s] to double. Invalid type: [%s]\",\n            valObj, valObj.getClass()\n        );\n      }\n      throw new ParseException(\n          valObj.getClass().toString(),\n          message\n      );\n    }\n  }\n\n  /**\n   * Convert a string representing a decimal value to a long.\n   * <p>\n   * If the decimal value is not an exact integral value (e.g. 42.0), or if the decimal value\n   * is too large to be contained within a long, this function returns null.\n   *\n   * @param decimalStr string representing a decimal value\n   * @return long equivalent of decimalStr, returns null for non-integral decimals and integral decimal values outside\n   * of the values representable by longs\n   */\n  @Nullable\n  public static Long getExactLongFromDecimalString(String decimalStr)","sourceCodeStart":744,"sourceCodeEnd":780,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java#L744-L780","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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).","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.","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.","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."],"exampleFix":"// before: passing raw JSON field that may be an object\nDouble v = DimensionHandlerUtils.convertObjectToDouble(row.getRaw(field), field);\n// after: guard and coerce only scalar numerics/strings\nObject raw = row.getRaw(field);\nDouble v = (raw instanceof Number || raw instanceof String)\n    ? DimensionHandlerUtils.convertObjectToDouble(raw, field)\n    : null; // or log/skip the row","handlingStrategy":"validation","validationCode":"static boolean isDoubleConvertible(Object v) {\n  return v instanceof Number || (v instanceof String && isNumeric((String) v));\n}\nprivate static boolean isNumeric(String s) {\n  try { Double.parseDouble(s); return true; } catch (NumberFormatException e) { return false; }\n}","typeGuard":"if (!(val instanceof Number) && !(val instanceof String)) {\n  throw new IllegalArgumentException(\"Expected numeric or numeric string, got: \" + val.getClass());\n}","tryCatchPattern":"try {\n  Double d = DimensionHandlerUtils.convertObjectToDouble(valObj, fieldName);\n} catch (ParseException pe) {\n  log.warn(\"Unparseable double for dimension [%s]: %s\", fieldName, pe.getMessage());\n  // route to reject/dead-letter path instead of failing the batch\n}","preventionTips":["Enforce schema on input so DOUBLE columns only receive numeric/numeric-string values.","Use a flattenSpec/transform to coerce or drop non-scalar fields before they reach typed dimensions.","Remember double columns cannot hold multi-value (List) values — flatten arrays upstream.","Catch ParseException per row and use Druid's parse-exception handling config rather than failing whole tasks."],"tags":["ingestion","parse-exception","type-mismatch","dimensions"],"backgroundTag":"invalid-argument-format","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}