Cannot build plan for query

I have a druid datasource with all the changes of orders and I want to get the last change for each order, I’m using the SQL Druid with the next query:

SELECT * FROM order_change AS change WHERE __time = (SELECT MAX(__time) FROM order_change WHERE order_id = change.order_id)

But I get an error in the response:

{“error”:“Unknown exception”,“errorMessage”:“Cannot build plan for query:SELECT * FROM order_change AS change WHERE __time = (SELECT MAX(__time) FROM order_change WHERE order_id = change.order_id)”,“errorClass”:“io.druid.java.util.common.ISE”,“host”:null}

does not Druid support this kind of subquery?

I have a similar problem. We upgraded Druid to 0.11.x and this query that used to work on 0.10.x :

SELECT “c-geo:c3” as country, COUNT(DISTINCT “diid”) as gwid, FLOOR(__time TO MONTH) as period FROM “gwiq-daily-p” WHERE (“cid” = ‘c0069’ AND (“c-geo:c3” = ‘aut’ OR “c-geo:c3” = ‘aus’ OR “c-geo:c3” = ‘arg’) AND (TIMESTAMP ‘2017-01-01 00:00:00’ <= __time AND __time <= TIMESTAMP ‘2018-02-28 00:00:00’)) AND (“cid” = ‘c0069’) GROUP BY “c-geo:c3”, FLOOR(__time TO MONTH)

``

doesn’t work anymore. I think the error points to :
FLOOR(__time TO MONTH) as period

``

I went through all PRs that have been made to Druid and I don’t see anything that could break it, any idea ?

Did you figure out the issue? I am getting a very similar error.

Hey Sakshi,

This kind of error happens when a query cannot be planned for some reason and could have a lot of causes (usually some SQL construct that Druid SQL doesn’t support). If you could post the specific query you’re running it might help figure out what is going on.