{"record":{"id":"e65866a0322a26e4","repo":"apache/druid","slug":"could-not-convert-value-s-to-double","errorCode":null,"errorMessage":"Could not convert value [%s] to double.","messagePattern":"Could not convert value \\[(.+?)\\] to double\\.","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java","lineNumber":725,"sourceCode":"    } else if (valObj instanceof Number) {\n      return ((Number) valObj).doubleValue();\n    } else if (valObj instanceof String) {\n      Double ret = Doubles.tryParse((String) valObj);\n      if (reportParseExceptions && ret == null) {\n        final String message;\n        if (fieldName != null) {\n          message = StringUtils.nonStrictFormat(\n              \"Could not convert value [%s] to double for dimension [%s].\",\n              valObj,\n              fieldName\n          );\n        } else {\n          message = StringUtils.nonStrictFormat(\n              \"Could not convert value [%s] to double.\",\n              valObj\n          );\n        }\n        throw new ParseException((String) valObj, message);\n      }\n      return ret;\n    } else if (valObj instanceof List) {\n      final String message;\n      if (fieldName != null) {\n        message = StringUtils.nonStrictFormat(\n            \"Could not ingest value [%s] as double for dimension [%s]. A double column cannot have multiple values in the same row.\",\n            valObj,\n            fieldName\n        );\n      } else {\n        message = StringUtils.nonStrictFormat(\n            \"Could not ingest value [%s] as double. A double column cannot have multiple values in the same row.\",\n            valObj\n        );\n      }\n\n      throw new ParseException(","sourceCodeStart":707,"sourceCodeEnd":743,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java#L707-L743","documentation":"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.","triggerScenarios":"Ingesting values like \"N/A\", \"\", or \"12.3.4\" into a double-typed column; convertObjectToDouble invoked on unparseable strings; also dispatched from convertObjectToType.","commonSituations":"Placeholder strings (\"null\", \"N/A\", \"-\") in numeric fields; locale-formatted decimals; corrupted CSV rows.","solutions":["Sanitize input with a transform (map \"N/A\"/\"-\" to null or 0 before CAST).","Fix upstream producers to emit valid doubles or explicit nulls.","Change the column to string type if values are not consistently numeric.","Increase maxParseExceptions or route errors to a handler to avoid job failure on isolated bad rows."],"exampleFix":"// before: value \"N/A\" fails Double.parseDouble\n// after: transform maps sentinels to null\n\"transforms\": [{\"type\": \"expression\", \"name\": \"amount\", \"expression\": \"case when amount in ('N/A','-','') then null else CAST(amount AS DOUBLE) end\"}]","handlingStrategy":"try-catch","validationCode":"boolean isParsableDouble(Object v) {\n  if (v == null) return true;\n  if (v instanceof Number) return true;\n  if (v instanceof String) {\n    String s = ((String) v).trim();\n    if (s.isEmpty() || s.equalsIgnoreCase(\"n/a\") || s.equals(\"-\")) return false;\n    try { Double.parseDouble(s); return true; } catch (NumberFormatException e) { return false; }\n  }\n  return false;\n}","typeGuard":"Double asDouble(Object v) {\n  if (v instanceof Number) return ((Number) v).doubleValue();\n  if (v instanceof String) { try { return Double.parseDouble((String) v); } catch (NumberFormatException e) { return null; } }\n  return null;\n}","tryCatchPattern":"try {\n  return DimensionHandlerUtils.convertObjectToDouble(value, fieldName);\n} catch (ParseException e) {\n  log.warn(\"Non-double value [%s] for field [%s], defaulting to null\", value, fieldName);\n  return null;\n}","preventionTips":["Map sentinel strings (\"N/A\", \"null\", \"-\") to null in transforms before CAST","Validate numeric fields with a double-parsing precheck in producers","Sample input rows in the ingestion wizard to confirm types","Use error handlers instead of failing jobs on isolated bad rows"],"tags":["ingestion","type-conversion","parse-exception"],"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"}