druidry icon indicating copy to clipboard operation
druidry copied to clipboard

In the examples, there is a bug around creating `DruidTopNQuery`

Open joybee-pp opened this issue 4 years ago • 1 comments

Screen Shot 2020-08-03 at 12 46 12

@GG-Zapr In the examples, there is a bug. When creating the DruidTopNQuery object, need to set the datasource. But it shouldn't be the String type. How can fix it?

joybee-pp avatar Aug 03 '20 03:08 joybee-pp

Hey @joybee-pp Thanks for pointing this out, we need to update README for fixing this example. Previously dataSource was simply String but now with druid supporting multiple type of data sources now datSource is an object of in.zapr.druid.druidry.dataSource.DataSource.

To achieve top N query like example, you could use TableDataSource like :

DruidTopNQuery query = DruidTopNQuery.builder()
        .dataSource(new TableDataSource("sample_data"))
        .dimension(dimension)
        .threshold(5)
        .topNMetric(metric)
        .granularity(granularity)
        .filter(filter)
        .aggregators(Arrays.asList(aggregator1, aggregator2))
        .postAggregators(Collections.singletonList(postAggregator))
        .intervals(Collections.singletonList(interval))
        .build();

abhi-zapr avatar Aug 30 '20 13:08 abhi-zapr