Skip to content
Snippets Groups Projects
Commit 199a93e3 authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-732: Incorporate lofar_image views by default

parent ef9dcae8
No related branches found
No related tags found
1 merge request!298Resolve L2SS-732 "Move lofar image views"
#!/bin/bash
psql << EOF
\c hdb
-- NOTE: We concatenate domain/family/member here, which means we can't index
-- the resulting column. However, queries also supply the attribute name,
-- which we can index. The scan on the device name is then limited to
-- entries which have the same attribute name across devices.
CREATE OR REPLACE VIEW lofar_scalar_double AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
0 AS x,
value_r as value
FROM att_scalar_devdouble att
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_devboolean AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
array_element.idx - 1 AS x,
array_element.val as value
FROM att_array_devboolean att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_devuchar AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
array_element.idx - 1 AS x,
array_element.val as value
FROM att_array_devuchar att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_devshort AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
array_element.idx - 1 AS x,
array_element.val as value
FROM att_array_devshort att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_devushort AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
array_element.idx - 1 AS x,
array_element.val as value
FROM att_array_devushort att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_devlong AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
array_element.idx - 1 AS x,
array_element.val as value
FROM att_array_devlong att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_devulong AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
array_element.idx - 1 AS x,
array_element.val as value
FROM att_array_devulong att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_devlong64 AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
array_element.idx - 1 AS x,
array_element.val as value
FROM att_array_devlong64 att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_devulong64 AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
array_element.idx - 1 AS x,
array_element.val as value
FROM att_array_devulong64 att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_devfloat AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
array_element.idx - 1 AS x,
array_element.val as value
FROM att_array_devfloat att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_devdouble AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
array_element.idx - 1 AS x,
array_element.val as value
FROM att_array_devdouble att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_devstring AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
array_element.idx - 1 AS x,
array_element.val as value
FROM att_array_devstring att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_devstate AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
array_element.idx - 1 AS x,
array_element.val as value
FROM att_array_devstate att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_devencoded AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
array_element.idx - 1 AS x,
array_element.val as value
FROM att_array_devencoded att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_devenum AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
array_element.idx - 1 AS x,
array_element.val as value
FROM att_array_devenum att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_image_devboolean AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devboolean att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_image_devuchar AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devuchar att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_image_devshort AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devshort att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_image_devushort AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devushort att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_image_devlong AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devlong att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_image_devulong AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devulong att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_image_devlong64 AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devlong64 att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_image_devulong64 AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devulong64 att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_image_devfloat AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devfloat att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_image_devdouble AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devdouble att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_image_devstring AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devstring att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_image_devstate AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devstate att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_image_devencoded AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devencoded att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_image_devenum AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devenum att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
EOF
...@@ -7,6 +7,21 @@ ...@@ -7,6 +7,21 @@
-- DOUBLE -- -- DOUBLE --
CREATE OR REPLACE VIEW lofar_image_double AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devdouble att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_double AS CREATE OR REPLACE VIEW lofar_array_double AS
SELECT SELECT
att.data_time AS data_time, att.data_time AS data_time,
...@@ -34,6 +49,21 @@ CREATE OR REPLACE VIEW lofar_array_double AS ...@@ -34,6 +49,21 @@ CREATE OR REPLACE VIEW lofar_array_double AS
-- BOOLEAN -- -- BOOLEAN --
CREATE OR REPLACE VIEW lofar_image_boolean AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
CASE WHEN array_element.val THEN 1 ELSE 0 END AS value
FROM att_image_devboolean att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_boolean AS CREATE OR REPLACE VIEW lofar_array_boolean AS
SELECT SELECT
att.data_time AS data_time, att.data_time AS data_time,
...@@ -60,6 +90,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS ...@@ -60,6 +90,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS
WHERE att.value_r IS NOT NULL; WHERE att.value_r IS NOT NULL;
-- UCHAR -- -- UCHAR --
CREATE OR REPLACE VIEW lofar_image_uchar AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devuchar att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_uchar AS CREATE OR REPLACE VIEW lofar_array_uchar AS
SELECT SELECT
att.data_time AS data_time, att.data_time AS data_time,
...@@ -86,6 +132,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS ...@@ -86,6 +132,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS
WHERE att.value_r IS NOT NULL; WHERE att.value_r IS NOT NULL;
-- SHORT -- -- SHORT --
CREATE OR REPLACE VIEW lofar_image_short AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devshort att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_short AS CREATE OR REPLACE VIEW lofar_array_short AS
SELECT SELECT
att.data_time AS data_time, att.data_time AS data_time,
...@@ -112,6 +174,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS ...@@ -112,6 +174,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS
WHERE att.value_r IS NOT NULL; WHERE att.value_r IS NOT NULL;
-- USHORT -- -- USHORT --
CREATE OR REPLACE VIEW lofar_image_ushort AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devushort att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_ushort AS CREATE OR REPLACE VIEW lofar_array_ushort AS
SELECT SELECT
att.data_time AS data_time, att.data_time AS data_time,
...@@ -138,6 +216,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS ...@@ -138,6 +216,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS
WHERE att.value_r IS NOT NULL; WHERE att.value_r IS NOT NULL;
-- LONG -- -- LONG --
CREATE OR REPLACE VIEW lofar_image_long AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devlong att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_long AS CREATE OR REPLACE VIEW lofar_array_long AS
SELECT SELECT
att.data_time AS data_time, att.data_time AS data_time,
...@@ -164,6 +258,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS ...@@ -164,6 +258,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS
WHERE att.value_r IS NOT NULL; WHERE att.value_r IS NOT NULL;
-- ULONG -- -- ULONG --
CREATE OR REPLACE VIEW lofar_image_ulong AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devulong att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_ulong AS CREATE OR REPLACE VIEW lofar_array_ulong AS
SELECT SELECT
att.data_time AS data_time, att.data_time AS data_time,
...@@ -190,6 +300,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS ...@@ -190,6 +300,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS
WHERE att.value_r IS NOT NULL; WHERE att.value_r IS NOT NULL;
-- LONG64 -- -- LONG64 --
CREATE OR REPLACE VIEW lofar_image_long64 AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devlong64 att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_long64 AS CREATE OR REPLACE VIEW lofar_array_long64 AS
SELECT SELECT
att.data_time AS data_time, att.data_time AS data_time,
...@@ -216,6 +342,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS ...@@ -216,6 +342,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS
WHERE att.value_r IS NOT NULL; WHERE att.value_r IS NOT NULL;
-- ULONG64 -- -- ULONG64 --
CREATE OR REPLACE VIEW lofar_image_ulong64 AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devulong64 att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_ulong64 AS CREATE OR REPLACE VIEW lofar_array_ulong64 AS
SELECT SELECT
att.data_time AS data_time, att.data_time AS data_time,
...@@ -242,6 +384,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS ...@@ -242,6 +384,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS
WHERE att.value_r IS NOT NULL; WHERE att.value_r IS NOT NULL;
-- FLOAT -- -- FLOAT --
CREATE OR REPLACE VIEW lofar_image_float AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devfloat att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_float AS CREATE OR REPLACE VIEW lofar_array_float AS
SELECT SELECT
att.data_time AS data_time, att.data_time AS data_time,
...@@ -268,6 +426,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS ...@@ -268,6 +426,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS
WHERE att.value_r IS NOT NULL; WHERE att.value_r IS NOT NULL;
-- STRING -- -- STRING --
CREATE OR REPLACE VIEW lofar_image_string AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devstring att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_string AS CREATE OR REPLACE VIEW lofar_array_string AS
SELECT SELECT
att.data_time AS data_time, att.data_time AS data_time,
...@@ -294,6 +468,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS ...@@ -294,6 +468,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS
WHERE att.value_r IS NOT NULL; WHERE att.value_r IS NOT NULL;
-- STATE -- -- STATE --
CREATE OR REPLACE VIEW lofar_image_state AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devstate att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_state AS CREATE OR REPLACE VIEW lofar_array_state AS
SELECT SELECT
att.data_time AS data_time, att.data_time AS data_time,
...@@ -320,6 +510,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS ...@@ -320,6 +510,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS
WHERE att.value_r IS NOT NULL; WHERE att.value_r IS NOT NULL;
-- ENCODED -- -- ENCODED --
CREATE OR REPLACE VIEW lofar_image_encoded AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devencoded att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_encoded AS CREATE OR REPLACE VIEW lofar_array_encoded AS
SELECT SELECT
att.data_time AS data_time, att.data_time AS data_time,
...@@ -346,6 +552,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS ...@@ -346,6 +552,22 @@ CREATE OR REPLACE VIEW lofar_array_double AS
WHERE att.value_r IS NOT NULL; WHERE att.value_r IS NOT NULL;
-- ENUM -- -- ENUM --
CREATE OR REPLACE VIEW lofar_image_enum AS
SELECT
att.data_time AS data_time,
CONCAT_WS('/', domain, family, member) AS device,
ac.name AS name,
(array_element.idx - 1) / ARRAY_LENGTH(att.value_r, 1) AS x,
(array_element.idx - 1) % ARRAY_LENGTH(att.value_r, 1) AS y,
array_element.val as value
FROM att_image_devenum att
-- add array values, and their index
JOIN LATERAL UNNEST(att.value_r) WITH ORDINALITY AS array_element(val,idx) ON TRUE
-- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL;
CREATE OR REPLACE VIEW lofar_array_enum AS CREATE OR REPLACE VIEW lofar_array_enum AS
SELECT SELECT
att.data_time AS data_time, att.data_time AS data_time,
...@@ -370,8 +592,3 @@ CREATE OR REPLACE VIEW lofar_scalar_enum AS ...@@ -370,8 +592,3 @@ CREATE OR REPLACE VIEW lofar_scalar_enum AS
-- add the device information -- add the device information
JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id JOIN att_conf ac ON att.att_conf_id = ac.att_conf_id
WHERE att.value_r IS NOT NULL; WHERE att.value_r IS NOT NULL;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment