Search code examples
sqltimestampepochdruid

Combine TIME_FLOOR and MILLIS_TO_TIMESTAMP in Apache Druid SQL query to get epoch timestamp


Could you please help me to figure out Apache Druid SQL request to get response with timestamp in milliseconds.

SELECT
"c_id", TIME_FLOOR("__time", 'PT24H') as __time, SUM(active_conn) as active_conn
FROM "mock_data"
WHERE "__time" BETWEEN TIMESTAMP '2021-03-03 00:00:00' AND TIMESTAMP '2021-03-18 00:00:00' AND "c_id" IN (0,3)  AND "customer_id" = 8526137
GROUP BY 1,2

getting

[["4","2021-03-18T00:00:00.000Z",639477945]]

want

[["4",1614776400000,639477945]]

Solution

  • You can probably use TIMESTAMP_TO_MILLIS(__time)