Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
tango
Commits
199a93e3
Commit
199a93e3
authored
Apr 5, 2022
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
L2SS-732
: Incorporate lofar_image views by default
parent
ef9dcae8
No related branches found
No related tags found
1 merge request
!298
Resolve L2SS-732 "Move lofar image views"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
docker-compose/timescaledb/resources/10_lofar_views.sh
+0
-427
0 additions, 427 deletions
docker-compose/timescaledb/resources/10_lofar_views.sh
docker-compose/timescaledb/resources/13_lofar_views.sql
+260
-43
260 additions, 43 deletions
docker-compose/timescaledb/resources/13_lofar_views.sql
with
260 additions
and
470 deletions
docker-compose/timescaledb/resources/10_lofar_views.sh
deleted
100644 → 0
+
0
−
427
View file @
ef9dcae8
#!/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
This diff is collapsed.
Click to expand it.
docker-compose/timescaledb/resources/13_lofar_views.sql
+
260
−
43
View file @
199a93e3
...
@@ -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
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment