FROM field using a subquery

I see that subqueries are possible with DP4 and I see an example in doc. Is something like this possible? If not how else can I run this?

FROM (SELECT Event FROM default LIMIT 10000);

We do not support subqueries in a FROM clause. It can usually be achieved using GROUP BY and WHERE.

In your example, did you want a GROUP BY?

Yes I missed the GROUP BY. But that still doesn’t solve the problem.

This is a pretty big database. So querying the whole database would take time. So I wanted to sample it for only 10,000 rows and then run the query.

I don’t want to build an index either as this query is a one-off ad-hoc query.

You are correct. We will be adding support for subqueries in the FROM clause. For now, you can do the following:

INSERT INTO tmp-bucket (KEY, VALUE) SELECT Event FROM … LIMIT 10000;

SELECT e, COUNT(*) FROM tmp-bucket GROUP BY …;

1 Like

Thanks. That should help.

Hi @ssingaram,

FYI, we did add support for subqueries in the FROM clause.