Can I simulate rank() or last() by a non __time dimension?

You probably know that Druid supports two query languages: Druid SQL and native. Under the hood, Druid translates SQL queries into its native query language, but you don’t need to worry about that if you’re coming straight from SQL.

That’s a bit of background to set up the question. You can read a bit more context and the use case here.

An answer is:

SELECT relevant_attributes
GROUP BY relevant_attributes including a key
HAVING time_column = MAX(time_column)

You can also glean a strategy from all of this: unleash your inner SQL ninja. Even if a SQL function isn’t currently supported by Druid SQL, it doesn’t mean that your results can’t be found through some logical and supported equivalent. Think about what you’d like your results to look like and go from there.