2020-06-15 18:57:40 +02:00
|
|
|
------------------------------------------------------
|
|
|
|
------------------------------------------------------
|
|
|
|
-- Additional relations
|
|
|
|
--
|
|
|
|
-- Licences related tables/views
|
|
|
|
------------------------------------------------------
|
|
|
|
------------------------------------------------------
|
2023-11-15 13:32:18 +01:00
|
|
|
DROP TABLE IF EXISTS ${stats_db_name}.publication_licenses purge;
|
|
|
|
|
2022-03-22 15:16:08 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS ${stats_db_name}.publication_licenses STORED AS PARQUET AS
|
2023-11-15 13:32:18 +01:00
|
|
|
SELECT substr(p.id, 4) as id, licenses.value as type
|
2020-06-15 18:57:40 +02:00
|
|
|
from ${openaire_db_name}.publication p LATERAL VIEW explode(p.instance.license) instances as licenses
|
2022-02-03 11:37:10 +01:00
|
|
|
where licenses.value is not null and licenses.value != '' and p.datainfo.deletedbyinference=false and p.datainfo.invisible = FALSE;
|
2020-06-15 18:57:40 +02:00
|
|
|
|
2023-11-15 13:32:18 +01:00
|
|
|
DROP TABLE IF EXISTS ${stats_db_name}.dataset_licenses purge;
|
|
|
|
|
2022-03-22 15:16:08 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS ${stats_db_name}.dataset_licenses STORED AS PARQUET AS
|
2020-06-15 18:57:40 +02:00
|
|
|
SELECT substr(p.id, 4) as id, licenses.value as type
|
|
|
|
from ${openaire_db_name}.dataset p LATERAL VIEW explode(p.instance.license) instances as licenses
|
2022-02-03 11:37:10 +01:00
|
|
|
where licenses.value is not null and licenses.value != '' and p.datainfo.deletedbyinference=false and p.datainfo.invisible = FALSE;
|
2020-06-15 18:57:40 +02:00
|
|
|
|
2023-11-15 13:32:18 +01:00
|
|
|
DROP TABLE IF EXISTS ${stats_db_name}.software_licenses purge;
|
|
|
|
|
2022-03-22 15:16:08 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS ${stats_db_name}.software_licenses STORED AS PARQUET AS
|
2020-06-15 18:57:40 +02:00
|
|
|
SELECT substr(p.id, 4) as id, licenses.value as type
|
|
|
|
from ${openaire_db_name}.software p LATERAL VIEW explode(p.instance.license) instances as licenses
|
2022-02-03 11:37:10 +01:00
|
|
|
where licenses.value is not null and licenses.value != '' and p.datainfo.deletedbyinference=false and p.datainfo.invisible = FALSE;
|
2020-06-15 18:57:40 +02:00
|
|
|
|
2023-11-15 13:32:18 +01:00
|
|
|
DROP TABLE IF EXISTS ${stats_db_name}.otherresearchproduct_licenses purge;
|
|
|
|
|
2022-03-22 15:16:08 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS ${stats_db_name}.otherresearchproduct_licenses STORED AS PARQUET AS
|
2020-06-15 18:57:40 +02:00
|
|
|
SELECT substr(p.id, 4) as id, licenses.value as type
|
|
|
|
from ${openaire_db_name}.otherresearchproduct p LATERAL VIEW explode(p.instance.license) instances as licenses
|
2022-02-03 11:37:10 +01:00
|
|
|
where licenses.value is not null and licenses.value != '' and p.datainfo.deletedbyinference=false and p.datainfo.invisible = FALSE;
|
2020-06-15 18:57:40 +02:00
|
|
|
|
|
|
|
CREATE VIEW IF NOT EXISTS ${stats_db_name}.result_licenses AS
|
|
|
|
SELECT * FROM ${stats_db_name}.publication_licenses
|
|
|
|
UNION ALL
|
|
|
|
SELECT * FROM ${stats_db_name}.dataset_licenses
|
|
|
|
UNION ALL
|
|
|
|
SELECT * FROM ${stats_db_name}.software_licenses
|
|
|
|
UNION ALL
|
|
|
|
SELECT * FROM ${stats_db_name}.otherresearchproduct_licenses;
|
|
|
|
|
2023-11-15 13:32:18 +01:00
|
|
|
DROP TABLE IF EXISTS ${stats_db_name}.organization_pids purge;
|
|
|
|
|
2022-03-22 15:16:08 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS ${stats_db_name}.organization_pids STORED AS PARQUET AS
|
2020-06-15 18:57:40 +02:00
|
|
|
select substr(o.id, 4) as id, ppid.qualifier.classname as type, ppid.value as pid
|
|
|
|
from ${openaire_db_name}.organization o lateral view explode(o.pid) pids as ppid;
|
|
|
|
|
2023-11-15 13:32:18 +01:00
|
|
|
DROP TABLE IF EXISTS ${stats_db_name}.organization_sources purge;
|
|
|
|
|
2022-03-22 15:16:08 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS ${stats_db_name}.organization_sources STORED AS PARQUET as
|
2020-06-15 18:57:40 +02:00
|
|
|
SELECT o.id, case when d.id is null then 'other' else o.datasource end as datasource
|
|
|
|
FROM (
|
|
|
|
SELECT substr(o.id, 4) as id, substr(instances.instance.key, 4) as datasource
|
|
|
|
from ${openaire_db_name}.organization o lateral view explode(o.collectedfrom) instances as instance) o
|
|
|
|
LEFT OUTER JOIN (
|
|
|
|
SELECT substr(d.id, 4) id
|
|
|
|
from ${openaire_db_name}.datasource d
|
2023-05-26 09:25:28 +02:00
|
|
|
WHERE d.datainfo.deletedbyinference=false and d.datainfo.invisible = FALSE) d on o.datasource = d.id;
|
|
|
|
|
2023-11-15 13:32:18 +01:00
|
|
|
DROP TABLE IF EXISTS ${stats_db_name}.result_accessroute purge;
|
|
|
|
|
2023-05-26 09:25:28 +02:00
|
|
|
CREATE TABLE IF NOT EXISTS ${stats_db_name}.result_accessroute STORED AS PARQUET as
|
2023-06-14 18:09:09 +02:00
|
|
|
select distinct substr(id,4) as id, accessroute from ${openaire_db_name}.result
|
2023-05-26 09:25:28 +02:00
|
|
|
lateral view explode (instance.accessright.openaccessroute) openaccessroute as accessroute;
|