DRUID SQL LATEST() and EARLIEST() returning zero

Viewed 1012

I have this data source in druid:

enter image description here

I'm trying to use LATEST() to return the latest coordinates of each user active in the last minute. My intention is to show their location in realtime using a mapbox chart in superset. This is my query:

SELECT LATEST(latitude), LATEST(longitude), user_id FROM locations
WHERE __time >= CURRENT_TIMESTAMP - INTERVAL '1' minute
GROUP BY user_id 

The problem is that LATEST() always return zero. Does anybody know what I'm doing wrong and how to achieve what I want using DRUID SQL? enter image description here

1 Answers

LATEST(expr) returns the latest value of expr, which must be numeric.

If your columns is not numeric, use LATEST(expr, maxBytesPerString)

e.g:

SELECT LATEST(latitude,16), LATEST(longitude,16), user_id FROM locations
WHERE __time >= CURRENT_TIMESTAMP - INTERVAL '1' minute
GROUP BY user_id 
Related