Skip to content

Instantly share code, notes, and snippets.

@GreenRover
Created May 28, 2015 18:39
Show Gist options
  • Save GreenRover/699e419de7b178e01c20 to your computer and use it in GitHub Desktop.
Save GreenRover/699e419de7b178e01c20 to your computer and use it in GitHub Desktop.
Cassandra aggragation trigger
update sensor_data_aggregated_hour_min
set min_value=sensor_data.value,
min_timestamp=sensor_data.timestamp
where
sensor=sensor_data.sensor
and aggregation='hour'
and timestamp=DATE_FORMAT(sensor_data.timestamp, '%Y-%m-%d %H:00:00+0200');
if sensor_data.value<min_value;
update sensor_data_aggregated_hour_max
set max_value=sensor_data.value,
max_timestamp=sensor_data.timestamp
where
sensor=sensor_data.sensor
and aggregation='hour'
and timestamp=DATE_FORMAT(sensor_data.timestamp, '%Y-%m-%d %H:00:00+0200');
if sensor_data.value>max_value;
update sensor_data_aggregated_day_min
set min_value=sensor_data.value,
min_timestamp=sensor_data.timestamp
where
sensor=sensor_data.sensor
and aggregation='day'
and timestamp=DATE_FORMAT(sensor_data.timestamp, '%Y-%m-%d 00:00:00+0200');
if sensor_data.value<min_value;
update sensor_data_aggregated_day_max
set max_value=sensor_data.value,
max_timestamp=sensor_data.timestamp
where
sensor=sensor_data.sensor
and aggregation='day'
and timestamp=DATE_FORMAT(sensor_data.timestamp, '%Y-%m-%d 00:00:00+0200');
if sensor_data.value>max_value;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment