{"record":{"id":"7d5b84dbc7b3b27c","repo":"apache/druid","slug":"unknown-value-type-7d5b84","errorCode":null,"errorMessage":"Unknown value type: ","messagePattern":"Unknown value type: ","errorType":"exception","errorClass":"org.apache.druid.java.util.common.ISE","httpStatus":null,"severity":"error","filePath":"extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/QuantilesPostAggregator.java","lineNumber":94,"sourceCode":"  {\n    Object val = values.get(fieldName);\n    if (val instanceof ApproximateHistogram) {\n      final ApproximateHistogram ah = (ApproximateHistogram) val;\n      return new Quantiles(probabilities, ah.getQuantiles(probabilities), ah.getMin(), ah.getMax());\n    } else if (val instanceof FixedBucketsHistogram) {\n      final FixedBucketsHistogram fbh = (FixedBucketsHistogram) val;\n      double[] adjustedProbabilites = new double[probabilities.length];\n      for (int i = 0; i < probabilities.length; i++) {\n        adjustedProbabilites[i] = probabilities[i] * 100.0;\n      }\n      return new Quantiles(\n          probabilities,\n          fbh.percentilesFloat(adjustedProbabilites),\n          (float) fbh.getMin(),\n          (float) fbh.getMax()\n      );\n    }\n    throw new ISE(\"Unknown value type: \" + val.getClass());\n  }\n\n  /**\n   * actual type is {@link Quantiles}\n   * @param signature\n   */\n  @Override\n  public ColumnType getType(ColumnInspector signature)\n  {\n    // todo: ???\n    return ColumnType.UNKNOWN_COMPLEX;\n  }\n\n  @Override\n  public PostAggregator decorate(Map<String, AggregatorFactory> aggregators)\n  {\n    return this;\n  }","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/QuantilesPostAggregator.java#L76-L112","documentation":"QuantilesPostAggregator.compute() throws IllegalStateException('Unknown value type: <class>') when the input value is neither an ApproximateHistogram nor a FixedBucketsHistogram; only those two histogram types support percentile computation via percentilesFloat/quantile.","triggerScenarios":"Applying a 'quantiles' post-aggregator to a field whose value is a scalar number, Quantiles object, or other non-histogram type produced by the aggregator or a previous post-agg.","commonSituations":"Chaining a quantiles post-agg on top of another quantiles output; pointing fieldName at a numeric metric; typos in field names resolving to the wrong column.","solutions":["Ensure fieldName references a metric/post-aggregator that outputs ApproximateHistogram or FixedBucketsHistogram.","Remove duplicate quantiles chaining; compute all needed quantiles in one QuantilesPostAggregator.","Verify the underlying aggregator type matches (approxHistogram vs fixedBucketsHistogram) and use the corresponding post-agg."],"exampleFix":"// before: quantiles on a quantiles result\n{\"type\": \"quantiles\", \"fieldName\": \"quantilesOut\", ...}\n// after: quantiles on the histogram metric\n{\"type\": \"quantiles\", \"fieldName\": \"myHistogram\", \"probabilities\": [0.5, 0.9]}","handlingStrategy":"type-guard","validationCode":"Object val = row.get(fieldName);\nif (!(val instanceof ApproximateHistogram) && !(val instanceof FixedBucketsHistogram)) {\n  throw new IllegalArgumentException(\"quantiles post-agg requires a histogram value, got \" + (val == null ? \"null\" : val.getClass()));\n}","typeGuard":"boolean isHistogram(Object v) {\n  return v instanceof ApproximateHistogram || v instanceof FixedBucketsHistogram;\n}","tryCatchPattern":"try {\n  Object q = quantilesPostAgg.compute(row);\n} catch (IllegalStateException e) {\n  if (e.getMessage().startsWith(\"Unknown value type\")) {\n    // rewire fieldName to the histogram metric\n  } else throw e;\n}","preventionTips":["Compute all desired quantiles in a single QuantilesPostAggregator on the raw histogram metric.","Do not chain quantiles post-aggs on top of each other.","Ensure the aggregation type matches the post-agg family (approxHistogram vs fixedBucketsHistogram)."],"tags":["druid","histogram","post-aggregator","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-14T11:17:12.474Z"}