Semantics of Druid topN query with limit and granularity is not equivalent to input SQL. In particular, limit is applied on each granularity value, not on the overall query.
Currently, the following query will be transformed into a topN query:
Previous query outputs at most 10 rows. In turn, the equivalent SQL query for a Druid topN query should be expressed as: