Datascketch timeseries query error (9.2.0)

When I query below statement, I got error message.
“ cannot be cast to”

How can I solve this problem?


“queryType”: “timeseries”,

“dataSource”: “datasketches_01”,

“intervals”: “2016-09-19T00Z/2016-09-20T00Z”,

“granularity”: “all”,

“context”: {

“timeout”: 40000


“aggregations”: [


“name”: “!Theta_uv”,

“type”: “thetaSketch”,

“fieldName”: “uv”




Did this start to appear in druid version 0.9.2 and was working fine before?

– Himanshu

Also, can you please find the exception trace for same in broker/historical log and provide?

– Himanshu

Here is broker log message.

java.lang.ClassCastException: cannot be cast to

at io.druid.query.aggregation.datasketches.theta.SketchMergeAggregatorFactory.finalizeComputation( ~[?:?]

at io.druid.query.aggregation.MetricManipulatorFns$2.manipulate( ~[druid-processing-0.9.2-rc2.jar:0.9.2-rc2]

at io.druid.query.timeseries.TimeseriesQueryQueryToolChest$6.apply( ~[druid-processing-0.9.2-rc2.jar:0.9.2-rc2]

at io.druid.query.timeseries.TimeseriesQueryQueryToolChest$6.apply( ~[druid-processing-0.9.2-rc2.jar:0.9.2-rc2]

at com.metamx.common.guava.MappingYieldingAccumulator.accumulate( ~[java-util-0.27.10.jar:?]

at io.druid.common.guava.CombiningSequence$CombiningYieldingAccumulator.accumulateLastValue( ~[druid-common-0.9.2-rc2.jar:0.9.2-rc2]

at io.druid.common.guava.CombiningSequence.makeYielder( ~[druid-common-0.9.2-rc2.jar:0.9.2-rc2]

at io.druid.common.guava.CombiningSequence.toYielder( ~[druid-common-0.9.2-rc2.jar:0.9.2-rc2]

at com.metamx.common.guava.MappedSequence.toYielder( ~[java-util-0.27.10.jar:?]

at io.druid.query.CPUTimeMetricQueryRunner$1.toYielder( ~[druid-processing-0.9.2-rc2.jar:0.9.2-rc2]

at com.metamx.common.guava.Sequences$1.toYielder( ~[java-util-0.27.10.jar:?]

at io.druid.server.QueryResource.doPost( [druid-server-0.9.2-rc2.jar:0.9.2-rc2]

at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source) ~[?:?]

at sun.reflect.DelegatingMethodAccessorImpl.invoke( ~[?:1.8.0_66]

at java.lang.reflect.Method.invoke( ~[?:1.8.0_66]


I found ‘combine’ function return ‘UnionImpl object’ .

Is needed convert to ‘Skectch object’ at appropriate time.


public Object combine(Object lhs, Object rhs)


final Union union;

if (lhs instanceof Union) {

union = (Union) lhs;

updateUnion(union, rhs);

} else if (rhs instanceof Union) {

union = (Union) rhs;

updateUnion(union, lhs);

} else {

union = (Union) SetOperation.builder().build(size, Family.UNION);

updateUnion(union, lhs); return ‘DirectCompactOrderedSketch’ to ‘UnionImpl’ Object

updateUnion(union, rhs); return ‘DirectCompactOrderedSketch’ to ‘UnionImpl’ Object


return union; --> finally return ‘UnionImpl’ Object


I changed some code and it looks working!


public Object finalizeComputation(Object object)


if (shouldFinalize) {

Sketch sketch = null;

if (object instanceof Sketch) {

sketch = (Sketch) object;

} else if (object instanceof Union) {

sketch = ((Union) object).getResult(true, null);


if (errorBoundsStdDev != null) {

SketchEstimateWithErrorBounds result = new SketchEstimateWithErrorBounds(





return result;

} else {

return sketch.getEstimate();


} else {

return object;




ah, that looks like a regression from a recent change.

thanks for reporting, we’ll fix it in next rc.

– Himanshu

FYI, was merged to 0.9.2 branch to fix this issue. It will get released with next RC.

– Himanshu