Multi-level sub query

I wanted to check if druid supports multi-level sub query. Looking at the example here, I couldn’t figure out if druid supports a multiple level subquery. Basically a group by query that looks like this:

…group by query(group by query(group by query (group query (table data source)))

If it does, where are the intermediate sub queries executed? Are they executed on the broker? Or are they pushed down to the historical nodes with the final merge (executing the outermost group by) on the broker? The website only says:

“Both strategy perform the outer query on the broker in a single-threaded fashion.”



Yes, Druid does support this kind of query, search the docs for “nested groupby”. It’s also supported through Druid SQL (

The inner grouping query is pushed down to the historical nodes, but all other levels above it are done on the broker.