{"record":{"id":"8049ed0bab151ab7","repo":"apache/druid","slug":"cannot-convert-object-to-double","errorCode":null,"errorMessage":"Cannot convert object to double","messagePattern":"Cannot convert object to double","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/UnnestColumnValueSelectorCursor.java","lineNumber":146,"sourceCode":"      @Override\n      public ColumnValueSelector makeColumnValueSelector(String columnName)\n      {\n        if (!outputName.equals(columnName)) {\n          return baseColumnSelectorFactory.makeColumnValueSelector(columnName);\n        }\n        return new ColumnValueSelector()\n        {\n          @Override\n          public double getDouble()\n          {\n            Object value = getObject();\n            if (value == null) {\n              return 0;\n            }\n            if (value instanceof Number) {\n              return ((Number) value).doubleValue();\n            }\n            throw new UOE(\"Cannot convert object to double\");\n          }\n\n          @Override\n          public float getFloat()\n          {\n            Object value = getObject();\n            if (value == null) {\n              return 0;\n            }\n            if (value instanceof Number) {\n              return ((Number) value).floatValue();\n            }\n            throw new UOE(\"Cannot convert object to float\");\n          }\n\n          @Override\n          public long getLong()\n          {","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/UnnestColumnValueSelectorCursor.java#L128-L164","documentation":"During UNNEST processing, the UnnestColumnValueSelectorCursor's primitive double accessor encounters a non-numeric, non-null object from the underlying column and throws UOE. The cursor only knows how to coerce Numbers (and null to 0); arbitrary objects (e.g. strings, complex objects) have no defined double conversion here.","triggerScenarios":"Unnesting a column whose values are objects that are neither null nor Number, then reading doubles via getDouble() (e.g. a numeric-typed query expecting double output over a column containing strings or complex values).","commonSituations":"Unnest input column mis-typed in schema (string values where numbers expected); using UNNEST on a nested-data/array column whose element objects are not numeric; expression output typed as complex fed into numeric aggregation.","solutions":["Ensure the unnest input column contains numeric values (fix ingestion typing or cast values upstream)","Cast/coerce values to numbers before unnesting (e.g. try_cast expressions, JSON value extraction with a numeric type)","Check the column's reported ValueType in the segment metadata; reingest or re-index with the correct type"],"exampleFix":"// before\n// unnest on column with string values, then SUM over it\n// after\n// add a virtual column: CAST(JSON_VALUE(col, '$.v') AS DOUBLE) and unnest/aggregate that","handlingStrategy":"type-guard","validationCode":"Object v = valueSelector.getObject();\nif (v instanceof Number) { double d = ((Number) v).doubleValue(); }","typeGuard":"static boolean isNumeric(Object o) { return o == null || o instanceof Number; }","tryCatchPattern":"try { double d = selector.getDouble(); } catch (UOE e) { /* treat as null/coerce via string parse */ }","preventionTips":["Verify column ValueType via segment metadata before numeric queries","Cast string values to numbers at ingestion time","Use SQL CAST for mixed-type columns"],"tags":["druid","unnest","type-mismatch"],"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"}