This repository has been archived by the owner on Oct 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from 7Last/develop
Develop
- Loading branch information
Showing
222 changed files
with
18,719 additions
and
4,861 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CREATE TABLE sensors.charging_efficiency | ||
( | ||
sensor_uuid UUID, | ||
sensor_names Array(String), | ||
group_name String, | ||
timestamp DateTime64, | ||
efficiency_rate Float64, | ||
utilization_rate Float64 | ||
) ENGINE = MergeTree() | ||
ORDER BY (sensor_uuid, timestamp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,71 @@ | ||
CREATE TABLE sensors.temperature_kafka | ||
( | ||
data String | ||
) ENGINE = Kafka('redpanda:9092', 'temperature', 'ch_group_1', 'JSONAsString'); | ||
|
||
CREATE TABLE sensors.temperatures | ||
CREATE TABLE sensors.temperature | ||
( | ||
sensor_uuid UUID, | ||
sensor_name String, | ||
group_name Nullable(String) default null, | ||
timestamp DateTime64, | ||
value Float32, | ||
latitude Float64, | ||
longitude Float64 | ||
) ENGINE = MergeTree() | ||
ORDER BY (sensor_uuid, timestamp); | ||
|
||
CREATE MATERIALIZED VIEW sensors.temperature_topic_mv TO sensors.temperatures as | ||
SELECT JSONExtractString(data, 'sensor_name') AS sensor_name, | ||
toUUID(JSONExtractString(data, 'sensor_uuid')) AS sensor_uuid, | ||
parseDateTime64BestEffort(JSONExtractString(data, 'timestamp')) AS timestamp, | ||
JSONExtractFloat(data, 'value') AS value, | ||
JSONExtractFloat(data, 'latitude') AS latitude, | ||
JSONExtractFloat(data, 'longitude') AS longitude | ||
FROM sensors.temperature_kafka; | ||
|
||
-- 5m averages | ||
CREATE TABLE sensors.temperatures_5m | ||
CREATE TABLE sensors.temperature_5m | ||
( | ||
sensor_name String, | ||
group_name Nullable(String) default null, | ||
date DateTime64, | ||
avg_temperature Float32, | ||
insertion_timestamp DateTime64(6) default now64() | ||
) ENGINE = MergeTree() | ||
ORDER BY (sensor_name, date); | ||
|
||
CREATE MATERIALIZED VIEW sensors.temperatures_5m_mv | ||
TO sensors.temperatures_5m AS | ||
CREATE MATERIALIZED VIEW sensors.temperature_5m_mv | ||
TO sensors.temperature_5m AS | ||
SELECT sensor_name, | ||
group_name, | ||
toStartOfFiveMinutes(timestamp) AS date, | ||
avg(value) AS avg_temperature | ||
FROM sensors.temperatures | ||
GROUP BY sensor_name, date; | ||
FROM sensors.temperature | ||
GROUP BY sensor_name, group_name, date; | ||
|
||
-- Weekly temperatures | ||
CREATE TABLE sensors.temperatures_weekly | ||
-- Weekly temperature | ||
CREATE TABLE sensors.temperature_weekly | ||
( | ||
sensor_name String, | ||
group_name Nullable(String) default null, | ||
date DateTime64, | ||
avg_temperature Float32, | ||
insertion_timestamp DateTime64(6) default now64() | ||
) ENGINE = MergeTree() | ||
ORDER BY (sensor_name, date); | ||
|
||
CREATE MATERIALIZED VIEW sensors.temperatures_weekly_mv | ||
TO sensors.temperatures_weekly AS | ||
CREATE MATERIALIZED VIEW sensors.temperature_weekly_mv | ||
TO sensors.temperature_weekly AS | ||
SELECT sensor_name, | ||
group_name, | ||
toStartOfWeek(timestamp) AS date, | ||
avg(value) AS avg_temperature | ||
FROM sensors.temperatures | ||
GROUP BY sensor_name, date; | ||
FROM sensors.temperature | ||
GROUP BY sensor_name, group_name, date; | ||
|
||
-- Daily temperatures | ||
CREATE TABLE sensors.temperatures_daily | ||
-- Daily temperature | ||
CREATE TABLE sensors.temperature_daily | ||
( | ||
sensor_name String, | ||
group_name Nullable(String) default null, | ||
date Date, | ||
avg_temperature Float32, | ||
insertion_timestamp DateTime64(6) default now64() | ||
) ENGINE = MergeTree() | ||
ORDER BY (sensor_name, date); | ||
|
||
CREATE MATERIALIZED VIEW sensors.temperatures_daily_mv | ||
TO sensors.temperatures_daily AS | ||
CREATE MATERIALIZED VIEW sensors.temperature_daily_mv | ||
TO sensors.temperature_daily AS | ||
SELECT sensor_name, | ||
group_name, | ||
toStartOfDay(timestamp) AS date, | ||
avg(value) AS avg_temperature | ||
FROM sensors.temperatures | ||
GROUP BY sensor_name, date; | ||
FROM sensors.temperature | ||
GROUP BY sensor_name, group_name, date; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,11 @@ | ||
CREATE TABLE sensors.recycling_point_kafka | ||
( | ||
data String | ||
) ENGINE = Kafka('redpanda:9092', 'recycling_point', 'ch_group_1', 'JSONAsString'); | ||
|
||
CREATE TABLE sensors.recycling_point | ||
( | ||
sensor_uuid UUID, | ||
sensor_name String, | ||
group_name Nullable(String) default null, | ||
timestamp DateTime64, | ||
latitude Float64, | ||
longitude Float64, | ||
filling_value Float32 | ||
filling Float32 | ||
) ENGINE = MergeTree() | ||
ORDER BY (sensor_uuid, timestamp); | ||
|
||
CREATE MATERIALIZED VIEW sensors.recycling_point_topic_mv TO sensors.recycling_point as | ||
SELECT JSONExtractString(data, 'sensor_name') AS sensor_name, | ||
toUUID(JSONExtractString(data, 'sensor_uuid')) AS sensor_uuid, | ||
parseDateTime64BestEffort(JSONExtractString(data, 'timestamp')) AS timestamp, | ||
JSONExtractFloat(data, 'filling_value') AS filling_value, | ||
JSONExtractFloat(data, 'latitude') AS latitude, | ||
JSONExtractFloat(data, 'longitude') AS longitude | ||
FROM sensors.recycling_point_kafka; | ||
|
||
CREATE TABLE sensors.recycling_point_5m | ||
( | ||
sensor_name String, | ||
date DateTime64, | ||
avg_filling_value Float32, | ||
insertion_timestamp DateTime64(6) default now64() | ||
) ENGINE = MergeTree() | ||
ORDER BY (sensor_name, date); | ||
|
||
CREATE MATERIALIZED VIEW sensors.recycling_point_5m_mv | ||
TO sensors.recycling_point_5m AS | ||
SELECT sensor_name, | ||
toStartOfFiveMinutes(timestamp) AS date, | ||
avg(filling_value) AS avg_filling_value | ||
from sensors.recycling_point | ||
GROUP BY sensor_name, date; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
CREATE TABLE sensors.humidity | ||
( | ||
sensor_uuid UUID, | ||
sensor_name String, | ||
group_name Nullable(String) default null, | ||
timestamp DateTime64, | ||
value Float32, | ||
latitude Float64, | ||
longitude Float64 | ||
) ENGINE = MergeTree() | ||
ORDER BY (sensor_uuid, timestamp); | ||
|
||
-- 5m averages | ||
CREATE TABLE sensors.humidity_5m | ||
( | ||
sensor_name String, | ||
date DateTime64, | ||
avg_humidity Float32, | ||
insertion_timestamp DateTime64(6) default now64() | ||
) ENGINE = MergeTree() | ||
ORDER BY (sensor_name, date); | ||
|
||
CREATE MATERIALIZED VIEW sensors.humidity_5m_mv | ||
TO sensors.humidity_5m AS | ||
SELECT sensor_name, | ||
toStartOfFiveMinutes(timestamp) AS date, | ||
avg(value) AS avg_humidity | ||
FROM sensors.humidity | ||
GROUP BY sensor_name, date; | ||
|
||
-- Weekly humidity | ||
CREATE TABLE sensors.humidity_weekly | ||
( | ||
sensor_name String, | ||
date DateTime64, | ||
avg_humidity Float32, | ||
insertion_timestamp DateTime64(6) default now64() | ||
) ENGINE = MergeTree() | ||
ORDER BY (sensor_name, date); | ||
|
||
CREATE MATERIALIZED VIEW sensors.humidity_weekly_mv | ||
TO sensors.humidity_weekly AS | ||
SELECT sensor_name, | ||
toStartOfWeek(timestamp) AS date, | ||
avg(value) AS avg_humidity | ||
FROM sensors.humidity | ||
GROUP BY sensor_name, date; | ||
|
||
-- Daily humidity | ||
CREATE TABLE sensors.humidity_daily | ||
( | ||
sensor_name String, | ||
date Date, | ||
avg_humidity Float32, | ||
insertion_timestamp DateTime64(6) default now64() | ||
) ENGINE = MergeTree() | ||
ORDER BY (sensor_name, date); | ||
|
||
CREATE MATERIALIZED VIEW sensors.humidity_daily_mv | ||
TO sensors.humidity_daily AS | ||
SELECT sensor_name, | ||
toStartOfDay(timestamp) AS date, | ||
avg(value) AS avg_humidity | ||
FROM sensors.humidity | ||
GROUP BY sensor_name, date; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CREATE TABLE sensors.air_quality | ||
( | ||
sensor_uuid UUID, | ||
sensor_name String, | ||
group_name Nullable(String) default null, | ||
timestamp DateTime64, | ||
latitude Float64, | ||
longitude Float64, | ||
pm25 Float32, | ||
pm10 Float32, | ||
no2 Float32, | ||
o3 Float32, | ||
so2 Float32 | ||
) ENGINE = MergeTree() | ||
ORDER BY (sensor_uuid, timestamp); |
Oops, something went wrong.