I have a query where I only need to select one dimension. I also have a namespace lookup configured in Druid for this dimension. I need to have the druid query return both the dimension value (an id in my case) as well as the namespace lookup value (which is a human readable name) for each record. I would like to use a topN query because it can be executed efficiently. However, it seems I am forced to use a groupBy query to return both the dimension value and the corresponding lookup value. I realize that in some cases two dimension values can map to the same lookup value and Druid will group by the lookup value. However, Druid supports the “injective” property which declares that there is a 1:1 mapping between dimension values and namespace lookup values. It should be possible to tell Druid to run a normal topN query and then perform the lookup mapping just before results are returned to the caller, perhaps in the broker.
Is there a way to get the performance benefits of a topN query which still having the query return both the dimension value and the corresponding lookup value. Thanks!