Datascketch timeseries query error (9.2.0)

When I query below statement, I got error message.
“com.yahoo.sketches.theta.UnionImpl cannot be cast to com.yahoo.sketches.theta.Sketch”

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: com.yahoo.sketches.theta.UnionImpl cannot be cast to com.yahoo.sketches.theta.Sketch

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Himanshu,

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

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

[SketchAggregatorFactory.java]

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!

[SketchMergeAggregatorFactory.java]

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(

sketch.getEstimate(),

sketch.getUpperBound(errorBoundsStdDev),

sketch.getLowerBound(errorBoundsStdDev),

errorBoundsStdDev);

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, https://github.com/druid-io/druid/pull/3621 was merged to 0.9.2 branch to fix this issue. It will get released with next RC.

– Himanshu