SQL to CQL: Time-Based Queries

In SQL data is organized by its structure, which may optionally include a date and/or time, but these values are not automatically added to each row of the table. As a log management system, LogScale stores every event with a time based on when the event occurred and when the event was ingested. This means that time is a critical part of the core data. Data is naturally returned in time order and is used to help drive query results and visualizations based on this time reference.

SQL CQL
  • Time is just another column

  • Temporal operations require explicit datetime functions

  • No inherent concept of "now" or relative time windows

  • Time-series analysis requires complex window functions

  • Time is a first-class citizen

  • Built-in support for relative time expressions (-24h, -7d)

  • Native time bucketing and windowing functions

  • Designed for temporal correlation and time-series analysis

sql
SELECT DATE_TRUNC('hour', event_time) as hour,
       COUNT(*) as event_count
FROM events
WHERE event_time >= NOW() - INTERVAL '24 hours'
GROUP BY DATE_TRUNC('hour', event_time)
ORDER BY hour;
logscale
| bucket(_time, "1h") 
| count() 
| timeChart(count)