{"record":{"id":"4858164bd7457893","repo":"apache/druid","slug":"could-not-convert-value-s-to-float-for-dimensio","errorCode":null,"errorMessage":"Could not convert value [%s] to float for dimension [%s]. Invalid type: [%s]","messagePattern":"Could not convert value \\[(.+?)\\] to float for dimension \\[(.+?)\\]\\. Invalid type: \\[(.+?)\\]","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java","lineNumber":551,"sourceCode":"            message\n        );\n      } else {\n        final String message;\n        if (fieldName != null) {\n          message = StringUtils.nonStrictFormat(\n              \"Could not convert value [%s] to float 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 float. Invalid type: [%s]\",\n              valObj,\n              valObj.getClass()\n          );\n        }\n        throw new ParseException(\n            valObj.getClass().toString(),\n            message\n        );\n      }\n    }\n  }\n\n  @Nullable\n  public static Object convertObjectToType(\n      @Nullable final Object obj,\n      final TypeSignature<ValueType> type,\n      final boolean reportParseExceptions,\n      @Nullable final String fieldName\n  )\n  {\n    Preconditions.checkNotNull(type, \"type\");\n\n    switch (type.getType()) {","sourceCodeStart":533,"sourceCodeEnd":569,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java#L533-L569","documentation":"convertObjectToFloat throws this ParseException when the value's runtime type is not convertible to float (not Number, String, or List — e.g. a Map or boolean). The message reports the value and its class.","triggerScenarios":"A float column receives a nested JSON object, boolean, or other unhandled Java type; convertObjectToFloat falls to the final else; also reachable via convertObjectToType.","commonSituations":"Nested payloads mapped directly to a numeric metric column; heterogeneous upstream schemas; auto-detection mistyping a column as float.","solutions":["Extract the numeric sub-field with a transform/json_query before conversion.","Correct upstream serialization so floats are plain numbers.","Type the column as string (or nested) if data is structured.","Validate the input schema against samples before submitting the ingestion spec."],"exampleFix":"// before: float column gets {\"v\": 1.2}\n// after: transform extracts v\n\"transforms\": [{\"type\": \"expression\", \"name\": \"v\", \"expression\": \"CAST(json_value(payload, '$.v') AS DOUBLE)\"}]","handlingStrategy":"type-guard","validationCode":"boolean convertibleToFloat(Object v) {\n  return v == null || v instanceof Number || v instanceof String;\n}","typeGuard":"Float asFloat(Object v) {\n  if (v instanceof Number) return ((Number) v).floatValue();\n  if (v instanceof String) { try { return Float.parseFloat((String) v); } catch (NumberFormatException e) { return null; } }\n  return null;\n}","tryCatchPattern":"try {\n  return DimensionHandlerUtils.convertObjectToFloat(value, fieldName);\n} catch (ParseException e) {\n  log.warn(\"Invalid type [%s] for float field [%s], dropping\", value.getClass(), fieldName);\n  return null;\n}","preventionTips":["Verify value.getClass() is Number or String before conversion","Extract numeric sub-fields from nested objects via json_value transforms","JSON-schema validate producer payloads","Watch for auto-detected column types on heterogeneous data"],"tags":["ingestion","type-conversion","invalid-type"],"backgroundTag":"type-mismatch","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"}