vogievetsky commented on issue #8208: Druid SQL: Fetch latest records from streaming ingestion URL: https://github.com/apache/incubator-druid/issues/8208#issuecomment-517483429 This is funny we were just talking about a very similar thing in the [Slack channel](https://druid.apache.org/community/join-slack) the other week... You can use ```sql SELECT * FROM wikipedia ORDER BY __time DESC LIMIT 1 ``` To get the latest ingested record this is the most efficient thing you can do. Your query logically would return all the records for the latest time, if that is really what you want to do that could be accomplished like so: ```sql SELECT * FROM wikipedia WHERE __time IN ( SELECT __time FROM wikipedia WHERE "__time" >= CURRENT_TIMESTAMP - INTERVAL '1' DAY GROUP BY 1 ORDER BY 1 DESC LIMIT 1 ) ``` ![image](https://user-images.githubusercontent.com/177816/62331909-45b0d900-b472-11e9-9927-1b644f182dd1.png) Your query does did not work because it can not plan the result of an aggregate (`MAX(__time)`) into a filter. The query above groups on time in the inner query. Notice also that I apply a filter to the inner query to not have to scan across the entire data set - I am assuming that my latest time will always be within the last day.
---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org For additional commands, e-mail: commits-h...@druid.apache.org