Skip to content
Snippets Groups Projects
Commit fb9a1bf9 authored by Stefano Di Frischia's avatar Stefano Di Frischia
Browse files

L2SS-406: add mask function to dbms

parent d920866b
Branches
Tags
1 merge request!190Resolve L2SS-406 "Grafana archiver"
......@@ -70,7 +70,7 @@
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "select name as \"Attribute\"\r\nfrom att_conf ac \r\nwhere \"domain\" ='stat' and \"family\" = 'sdp' and \"member\" ='1'\r\norder by name",
"rawSql": "select name as \"Attribute\",\r\ntable_name as \"Type\"\r\nfrom att_conf ac \r\nwhere \"domain\" ='stat' and \"family\" = 'sdp' and \"member\" ='1'\r\norder by name",
"refId": "A",
"select": [
[
......@@ -142,7 +142,7 @@
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "select name as \"Attribute\" \r\nfrom att_conf ac \r\nwhere \"domain\" ='stat' and \"family\" = 'recv' and \"member\" ='1'\r\norder by name",
"rawSql": "select name as \"Attribute\",\r\ntable_name as \"Type\" \r\nfrom att_conf ac \r\nwhere \"domain\" ='stat' and \"family\" = 'recv' and \"member\" ='1'\r\norder by name",
"refId": "A",
"select": [
[
......
......@@ -5,5 +5,6 @@ COPY resources/01_admin.sql docker-entrypoint-initdb.d/002_admin.sql
COPY resources/02_hdb_schema.sql docker-entrypoint-initdb.d/003_hdb_schema.sql
COPY resources/03_hdb_roles.sql docker-entrypoint-initdb.d/004_hdb_roles.sql
COPY resources/04_hdb_ext_aggregates.sql docker-entrypoint-initdb.d/005_hdb_ext_aggregates.sql
COPY resources/05_lofar_views.sql docker-entrypoint-initdb.d/006_lofar_views.sql
COPY resources/06_cleanup.sql docker-entrypoint-initdb.d/007_cleanup.sql
COPY resources/05_lofar_func.sh docker-entrypoint-initdb.d/006_lofar_func.sh
COPY resources/06_lofar_views.sql docker-entrypoint-initdb.d/007_lofar_views.sql
COPY resources/07_cleanup.sql docker-entrypoint-initdb.d/008_cleanup.sql
#!/bin/bash
psql << EOF
\c hdb
CREATE OR REPLACE FUNCTION mask(double precision[], boolean[])
RETURNS double precision[] LANGUAGE sql
AS \$function\$ SELECT ARRAY(SELECT
case when \$2[i] then \$1[i]
else '0'::double precision end
FROM generate_subscripts(\$1,1) g(i)) \$function\$;
EOF
......@@ -28,13 +28,8 @@ ORDER BY aab.data_time;
-- SDP Masked values (rounded to 1 second)
create or replace view "sdp_masked_temp_values" as
select time_bucket('1 second',t.time) as "temp_time",
time_bucket('1 second',m.time) as "mask_time",
t.value_r as "temperature",
m.value_r as "mask"
mask(t.value_r,m.value_r) as "temperature"
from sdp_fpga_temp as t
inner join sdp_tr_fpga_mask as m
on time_bucket('1 second',t.time) = time_bucket('1 second',m.time)
inner join generate_series(1,16) gs
on m.value_r[gs]=true
group by t."time", m."time",t.value_r,m.value_r
order by t."time";
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment