gianm commented on a change in pull request #8775: Fix NPE for subquery with
limit
URL: https://github.com/apache/incubator-druid/pull/8775#discussion_r340945489
##########
File path:
sql/src/test/java/org/apache/druid/sql/calcite/http/SqlResourceTest.java
##########
@@ -671,6 +671,48 @@ public void testResourceLimitExceeded() throws Exception
checkSqlRequestLog(false);
}
+ @Test
+ public void testSubQueryWithLimit() throws Exception
+ {
+ final List<Map<String, Object>> rows = doPost(
+ new SqlQuery(
+ "SELECT COUNT(*) AS cnt FROM ( SELECT * FROM ( SELECT * FROM
druid.foo LIMIT 10 ) tmpA ) tmpB",
Review comment:
I think a query like this is actually legitimately unplannable in Druid
today. It is an aggregation query on top of a non-aggregating subquery.
Currently, groupBy subqueries must also be groupBys.
I think that to really fix this bug, we need to really support groupBys with
something other than a groupBy as a subquery. To make this work, we could
potentially build on point (3) in "native queries" of the join proposal
https://github.com/apache/incubator-druid/issues/8728:
> Allow joining on to "query" datasources as well. To make this work, we’ll
need to add a sense of a ‘standard translation’ of results from certain query
types into flat schemas that we can offer column selectors on top of. There may
be more than one way to do this, since certain query types (notably, topN and
scan) return nested results in some cases. We could do this by adding a new
QueryToolChest method.
The "standard translation" could also be used to support running a groupBy
on top of a non-aggregating subquery.
Something to think about for the future.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]