forked from D-Net/dnet-hadoop
Update step16-createIndicatorsTables.sql
Change scripts for gold, hybrid, bronze indicators
This commit is contained in:
parent
9ef971a146
commit
489a082f04
|
@ -1,4 +1,6 @@
|
|||
-- Sprint 1 ----
|
||||
drop table if exists ${stats_db_name}.indi_pub_green_oa purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_green_oa stored as parquet as
|
||||
select distinct p.id, coalesce(green_oa, 0) as green_oa
|
||||
from ${stats_db_name}.publication p
|
||||
|
@ -12,6 +14,8 @@ from ${stats_db_name}.publication p
|
|||
or ri.accessright = 'Embargo' or ri.accessright = 'Open Source')) tmp
|
||||
on p.id= tmp.id;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_pub_grey_lit purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_grey_lit stored as parquet as
|
||||
select distinct p.id, coalesce(grey_lit, 0) as grey_lit
|
||||
from ${stats_db_name}.publication p
|
||||
|
@ -23,6 +27,8 @@ from ${stats_db_name}.publication p
|
|||
not exists (select 1 from ${stats_db_name}.result_classifications rc where type ='Other literature type'
|
||||
and rc.id=p.id)) tmp on p.id=tmp.id;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_pub_doi_from_crossref purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_doi_from_crossref stored as parquet as
|
||||
select distinct p.id, coalesce(doi_from_crossref, 0) as doi_from_crossref
|
||||
from ${stats_db_name}.publication p
|
||||
|
@ -33,6 +39,8 @@ from ${stats_db_name}.publication p
|
|||
on tmp.id=p.id;
|
||||
|
||||
-- Sprint 2 ----
|
||||
drop table if exists ${stats_db_name}.indi_result_has_cc_licence purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_result_has_cc_licence stored as parquet as
|
||||
select distinct r.id, (case when lic='' or lic is null then 0 else 1 end) as has_cc_license
|
||||
from ${stats_db_name}.result r
|
||||
|
@ -41,6 +49,8 @@ left outer join (select r.id, license.type as lic from ${stats_db_name}.result r
|
|||
where lower(license.type) LIKE '%creativecommons.org%' OR lower(license.type) LIKE '%cc-%') tmp
|
||||
on r.id= tmp.id;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_result_has_cc_licence_url purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_result_has_cc_licence_url stored as parquet as
|
||||
select distinct r.id, case when lic_host='' or lic_host is null then 0 else 1 end as has_cc_license_url
|
||||
from ${stats_db_name}.result r
|
||||
|
@ -50,10 +60,14 @@ from ${stats_db_name}.result r
|
|||
WHERE lower(parse_url(license.type, "HOST")) = "creativecommons.org") tmp
|
||||
on r.id= tmp.id;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_pub_has_abstract purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_has_abstract stored as parquet as
|
||||
select distinct publication.id, cast(coalesce(abstract, true) as int) has_abstract
|
||||
from ${stats_db_name}.publication;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_result_with_orcid purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_result_with_orcid stored as parquet as
|
||||
select distinct r.id, coalesce(has_orcid, 0) as has_orcid
|
||||
from ${stats_db_name}.result r
|
||||
|
@ -61,6 +75,9 @@ from ${stats_db_name}.result r
|
|||
on r.id= tmp.id;
|
||||
|
||||
---- Sprint 3 ----
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_funded_result_with_fundref purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_funded_result_with_fundref stored as parquet as
|
||||
select distinct r.result as id, coalesce(fundref, 0) as fundref
|
||||
from ${stats_db_name}.project_results r
|
||||
|
@ -79,6 +96,8 @@ from ${stats_db_name}.project_results r
|
|||
create TEMPORARY TABLE ${stats_db_name}.tmp AS SELECT ro.organization organization, ro.id, o.name from ${stats_db_name}.result_organization ro
|
||||
join ${stats_db_name}.organization o on o.id=ro.organization where o.name is not null;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_result_org_collab purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_result_org_collab stored as parquet as
|
||||
select o1.organization org1, o1.name org1name1, o2.organization org2, o2.name org2name2, count(o1.id) as collaborations
|
||||
from ${stats_db_name}.tmp as o1
|
||||
|
@ -91,6 +110,8 @@ create TEMPORARY TABLE ${stats_db_name}.tmp AS
|
|||
select distinct ro.organization organization, ro.id, o.name, o.country from ${stats_db_name}.result_organization ro
|
||||
join ${stats_db_name}.organization o on o.id=ro.organization where country <> 'UNKNOWN' and o.name is not null;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_result_org_country_collab purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_result_org_country_collab stored as parquet as
|
||||
select o1.organization org1,o1.name org1name1, o2.country country2, count(o1.id) as collaborations
|
||||
from ${stats_db_name}.tmp as o1 join ${stats_db_name}.tmp as o2 on o1.id=o2.id
|
||||
|
@ -103,6 +124,8 @@ create TEMPORARY TABLE ${stats_db_name}.tmp AS
|
|||
select o.id organization, o.name, ro.project as project from ${stats_db_name}.organization o
|
||||
join ${stats_db_name}.organization_projects ro on o.id=ro.id where o.name is not null;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_project_collab_org purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_project_collab_org stored as parquet as
|
||||
select o1.organization org1,o1.name orgname1, o2.organization org2, o2.name orgname2, count(distinct o1.project) as collaborations
|
||||
from ${stats_db_name}.tmp as o1
|
||||
|
@ -117,6 +140,8 @@ select o.id organization, o.name, o.country , ro.project as project from ${stat
|
|||
join ${stats_db_name}.organization_projects ro on o.id=ro.id
|
||||
and o.country <> 'UNKNOWN' and o.name is not null;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_project_collab_org_country purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_project_collab_org_country stored as parquet as
|
||||
select o1.organization org1,o1.name org1name, o2.country country2, count(distinct o1.project) as collaborations
|
||||
from ${stats_db_name}.tmp as o1
|
||||
|
@ -126,6 +151,8 @@ group by o1.organization, o2.country, o1.name;
|
|||
|
||||
drop table ${stats_db_name}.tmp purge;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_funder_country_collab purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_funder_country_collab stored as parquet as
|
||||
with tmp as (select funder, project, country from ${stats_db_name}.organization_projects op
|
||||
join ${stats_db_name}.organization o on o.id=op.id
|
||||
|
@ -142,6 +169,8 @@ select distinct country, ro.id as result from ${stats_db_name}.organization o
|
|||
join ${stats_db_name}.result_organization ro on o.id=ro.organization
|
||||
where country <> 'UNKNOWN' and o.name is not null;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_result_country_collab purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_result_country_collab stored as parquet as
|
||||
select o1.country country1, o2.country country2, count(o1.result) as collaborations
|
||||
from ${stats_db_name}.tmp as o1
|
||||
|
@ -152,6 +181,8 @@ group by o1.country, o2.country;
|
|||
drop table ${stats_db_name}.tmp purge;
|
||||
|
||||
---- Sprint 4 ----
|
||||
drop table if exists ${stats_db_name}.indi_pub_diamond purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_diamond stored as parquet as
|
||||
select distinct pd.id, coalesce(in_diamond_journal, 0) as in_diamond_journal
|
||||
from ${stats_db_name}.publication_datasources pd
|
||||
|
@ -162,6 +193,8 @@ from ${stats_db_name}.publication_datasources pd
|
|||
and (ps.journal_is_in_doaj=true or ps.journal_is_oa=true) and ps.has_apc=false) tmp
|
||||
on pd.id=tmp.id;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_pub_in_transformative purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_in_transformative stored as parquet as
|
||||
select distinct pd.id, coalesce(is_transformative, 0) as is_transformative
|
||||
from ${stats_db_name}.publication pd
|
||||
|
@ -172,6 +205,8 @@ from ${stats_db_name}.publication pd
|
|||
and ps.is_transformative_journal=true) tmp
|
||||
on pd.id=tmp.id;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_pub_closed_other_open purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_closed_other_open stored as parquet as
|
||||
select distinct ri.id, coalesce(pub_closed_other_open, 0) as pub_closed_other_open from ${stats_db_name}.result_instance ri
|
||||
left outer join
|
||||
|
@ -183,10 +218,14 @@ select distinct ri.id, coalesce(pub_closed_other_open, 0) as pub_closed_other_op
|
|||
on tmp.id=ri.id;
|
||||
|
||||
---- Sprint 5 ----
|
||||
drop table if exists ${stats_db_name}.indi_result_no_of_copies purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_result_no_of_copies stored as parquet as
|
||||
select id, count(id) as number_of_copies from ${stats_db_name}.result_instance group by id;
|
||||
|
||||
---- Sprint 6 ----
|
||||
drop table if exists ${stats_db_name}.indi_pub_downloads purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_downloads stored as parquet as
|
||||
SELECT result_id, sum(downloads) no_downloads from openaire_prod_usage_stats.usage_stats
|
||||
join ${stats_db_name}.publication on result_id=id
|
||||
|
@ -196,6 +235,8 @@ order by no_downloads desc;
|
|||
|
||||
--ANALYZE TABLE ${stats_db_name}.indi_pub_downloads COMPUTE STATISTICS;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_pub_downloads_datasource purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_downloads_datasource stored as parquet as
|
||||
SELECT result_id, repository_id, sum(downloads) no_downloads from openaire_prod_usage_stats.usage_stats
|
||||
join ${stats_db_name}.publication on result_id=id
|
||||
|
@ -203,12 +244,16 @@ where downloads>0
|
|||
GROUP BY result_id, repository_id
|
||||
order by result_id;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_pub_downloads_year purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_downloads_year stored as parquet as
|
||||
SELECT result_id, cast(substring(us.`date`, 1,4) as int) as `year`, sum(downloads) no_downloads
|
||||
from openaire_prod_usage_stats.usage_stats us
|
||||
join ${stats_db_name}.publication on result_id=id where downloads>0
|
||||
GROUP BY result_id, substring(us.`date`, 1,4);
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_pub_downloads_datasource_year purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_downloads_datasource_year stored as parquet as
|
||||
SELECT result_id, cast(substring(us.`date`, 1,4) as int) as `year`, repository_id, sum(downloads) no_downloads from openaire_prod_usage_stats.usage_stats us
|
||||
join ${stats_db_name}.publication on result_id=id
|
||||
|
@ -216,54 +261,81 @@ where downloads>0
|
|||
GROUP BY result_id, repository_id, substring(us.`date`, 1,4);
|
||||
|
||||
---- Sprint 7 ----
|
||||
drop table if exists ${stats_db_name}.indi_pub_gold_oa purge;
|
||||
|
||||
--create table if not exists ${stats_db_name}.indi_pub_gold_oa stored as parquet as
|
||||
-- WITH gold_oa AS ( SELECT
|
||||
-- issn_l,
|
||||
-- journal_is_in_doaj,
|
||||
-- journal_is_oa,
|
||||
-- issn_1 as issn
|
||||
-- FROM
|
||||
-- STATS_EXT.oa_journals
|
||||
-- WHERE
|
||||
-- issn_1 != ""
|
||||
-- UNION
|
||||
-- ALL SELECT
|
||||
-- issn_l,
|
||||
-- journal_is_in_doaj,
|
||||
-- journal_is_oa,
|
||||
-- issn_2 as issn
|
||||
-- FROM
|
||||
-- STATS_EXT.oa_journals
|
||||
-- WHERE
|
||||
-- issn_2 != "" ), issn AS ( SELECT
|
||||
-- *
|
||||
-- FROM
|
||||
--( SELECT
|
||||
-- id,
|
||||
-- issn_printed as issn
|
||||
-- FROM
|
||||
-- ${stats_db_name}.datasource
|
||||
-- WHERE
|
||||
-- issn_printed IS NOT NULL
|
||||
-- UNION ALL
|
||||
-- SELECT
|
||||
-- id,
|
||||
-- issn_online as issn
|
||||
-- FROM
|
||||
-- ${stats_db_name}.datasource
|
||||
-- WHERE
|
||||
-- issn_online IS NOT NULL or id like '%doajarticles%') as issn
|
||||
-- WHERE
|
||||
-- LENGTH(issn) > 7)
|
||||
--SELECT
|
||||
-- DISTINCT pd.id, coalesce(is_gold, 0) as is_gold
|
||||
--FROM
|
||||
-- ${stats_db_name}.publication_datasources pd
|
||||
-- left outer join(
|
||||
-- select pd.id, 1 as is_gold FROM ${stats_db_name}.publication_datasources pd
|
||||
-- JOIN issn on issn.id=pd.datasource
|
||||
-- JOIN gold_oa on issn.issn = gold_oa.issn) tmp
|
||||
-- on pd.id=tmp.id;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_gold_oa stored as parquet as
|
||||
WITH gold_oa AS ( SELECT
|
||||
issn_l,
|
||||
journal_is_in_doaj,
|
||||
journal_is_oa,
|
||||
issn_1 as issn
|
||||
FROM
|
||||
STATS_EXT.oa_journals
|
||||
WHERE
|
||||
issn_1 != ""
|
||||
UNION
|
||||
ALL SELECT
|
||||
issn_l,
|
||||
journal_is_in_doaj,
|
||||
journal_is_oa,
|
||||
issn_2 as issn
|
||||
FROM
|
||||
STATS_EXT.oa_journals
|
||||
WHERE
|
||||
issn_2 != "" ), issn AS ( SELECT
|
||||
*
|
||||
FROM
|
||||
( SELECT
|
||||
id,
|
||||
issn_printed as issn
|
||||
FROM
|
||||
${stats_db_name}.datasource
|
||||
WHERE
|
||||
issn_printed IS NOT NULL
|
||||
UNION ALL
|
||||
SELECT
|
||||
id,
|
||||
issn_online as issn
|
||||
FROM
|
||||
${stats_db_name}.datasource
|
||||
WHERE
|
||||
issn_online IS NOT NULL or id like '%doajarticles%') as issn
|
||||
WHERE
|
||||
LENGTH(issn) > 7)
|
||||
SELECT
|
||||
DISTINCT pd.id, coalesce(is_gold, 0) as is_gold
|
||||
FROM
|
||||
${stats_db_name}.publication_datasources pd
|
||||
left outer join(
|
||||
select pd.id, 1 as is_gold FROM ${stats_db_name}.publication_datasources pd
|
||||
JOIN issn on issn.id=pd.datasource
|
||||
JOIN gold_oa on issn.issn = gold_oa.issn) tmp
|
||||
on pd.id=tmp.id;
|
||||
with gold_oa as (
|
||||
SELECT issn,issn_l from stats_ext.issn_gold_oa_dataset_v5),
|
||||
issn AS (SELECT * FROM
|
||||
(SELECT id,issn_printed as issn FROM ${stats_db_name}.datasource
|
||||
WHERE issn_printed IS NOT NULL
|
||||
UNION ALL
|
||||
SELECT id, issn_online as issn FROM ${stats_db_name}.datasource
|
||||
WHERE issn_online IS NOT NULL or id like '%doajarticles%') as issn
|
||||
WHERE LENGTH(issn) > 7),
|
||||
alljournals AS(select issn, issn_l from stats_ext.alljournals
|
||||
where journal_is_in_doaj=true or journal_is_oa=true)
|
||||
SELECT DISTINCT pd.id, coalesce(is_gold, 0) as is_gold
|
||||
FROM ${stats_db_name}.publication_datasources pd
|
||||
left outer join (
|
||||
select pd.id, 1 as is_gold FROM ${stats_db_name}.publication_datasources pd
|
||||
JOIN issn on issn.id=pd.datasource
|
||||
JOIN gold_oa on issn.issn = gold_oa.issn
|
||||
join alljournals on issn.issn=alljournals.issn
|
||||
left outer join ${stats_db_name}.result_instance ri on ri.id=pd.id
|
||||
and ri.accessright!='Closed Access' and ri.accessright_uw='gold') tmp
|
||||
on pd.id=tmp.id;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_pub_hybrid_oa_with_cc purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_hybrid_oa_with_cc stored as parquet as
|
||||
WITH hybrid_oa AS (
|
||||
|
@ -296,56 +368,71 @@ FROM ${stats_db_name}.publication_datasources pd
|
|||
JOIN ${stats_db_name}.indi_pub_gold_oa ga on pd.id=ga.id
|
||||
where cc.has_cc_license=1 and ga.is_gold=0) tmp on pd.id=tmp.id;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_pub_hybrid purge;
|
||||
|
||||
--create table if not exists ${stats_db_name}.indi_pub_hybrid stored as parquet as
|
||||
-- WITH gold_oa AS ( SELECT
|
||||
-- issn_l,
|
||||
-- journal_is_in_doaj,
|
||||
-- journal_is_oa,
|
||||
-- issn_1 as issn,
|
||||
-- has_apc
|
||||
-- FROM
|
||||
-- STATS_EXT.oa_journals
|
||||
-- WHERE
|
||||
-- issn_1 != ""
|
||||
-- UNION
|
||||
-- ALL SELECT
|
||||
-- issn_l,
|
||||
-- journal_is_in_doaj,
|
||||
-- journal_is_oa,
|
||||
-- issn_2 as issn,
|
||||
-- has_apc
|
||||
-- FROM
|
||||
-- STATS_EXT.oa_journals
|
||||
-- WHERE
|
||||
-- issn_2 != "" ), issn AS ( SELECT
|
||||
-- *
|
||||
-- FROM
|
||||
--( SELECT
|
||||
-- id,
|
||||
-- issn_printed as issn
|
||||
-- FROM
|
||||
-- ${stats_db_name}.datasource
|
||||
-- WHERE
|
||||
-- issn_printed IS NOT NULL
|
||||
-- UNION ALL
|
||||
-- SELECT
|
||||
-- id,
|
||||
-- issn_online as issn
|
||||
-- FROM
|
||||
-- ${stats_db_name}.datasource
|
||||
-- WHERE
|
||||
-- issn_online IS NOT NULL or id like '%doajarticles%') as issn
|
||||
-- WHERE
|
||||
-- LENGTH(issn) > 7)
|
||||
--select distinct pd.id, coalesce(is_hybrid, 0) as is_hybrid
|
||||
--from ${stats_db_name}.publication_datasources pd
|
||||
-- left outer join (
|
||||
-- select pd.id, 1 as is_hybrid from ${stats_db_name}.publication_datasources pd
|
||||
-- join ${stats_db_name}.datasource d on d.id=pd.datasource
|
||||
-- join issn on issn.id=pd.datasource
|
||||
-- join gold_oa on issn.issn=gold_oa.issn
|
||||
-- where (gold_oa.journal_is_in_doaj=false or gold_oa.journal_is_oa=false))tmp
|
||||
-- on pd.id=tmp.id;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_hybrid stored as parquet as
|
||||
WITH gold_oa AS ( SELECT
|
||||
issn_l,
|
||||
journal_is_in_doaj,
|
||||
journal_is_oa,
|
||||
issn_1 as issn,
|
||||
has_apc
|
||||
FROM
|
||||
STATS_EXT.oa_journals
|
||||
WHERE
|
||||
issn_1 != ""
|
||||
UNION
|
||||
ALL SELECT
|
||||
issn_l,
|
||||
journal_is_in_doaj,
|
||||
journal_is_oa,
|
||||
issn_2 as issn,
|
||||
has_apc
|
||||
FROM
|
||||
STATS_EXT.oa_journals
|
||||
WHERE
|
||||
issn_2 != "" ), issn AS ( SELECT
|
||||
*
|
||||
FROM
|
||||
( SELECT
|
||||
id,
|
||||
issn_printed as issn
|
||||
FROM
|
||||
${stats_db_name}.datasource
|
||||
WHERE
|
||||
issn_printed IS NOT NULL
|
||||
UNION ALL
|
||||
SELECT
|
||||
id,
|
||||
issn_online as issn
|
||||
FROM
|
||||
${stats_db_name}.datasource
|
||||
WHERE
|
||||
issn_online IS NOT NULL or id like '%doajarticles%') as issn
|
||||
WHERE
|
||||
LENGTH(issn) > 7)
|
||||
select distinct pd.id, coalesce(is_hybrid, 0) as is_hybrid
|
||||
from ${stats_db_name}.publication_datasources pd
|
||||
left outer join (
|
||||
select pd.id, 1 as is_hybrid from ${stats_db_name}.publication_datasources pd
|
||||
join ${stats_db_name}.datasource d on d.id=pd.datasource
|
||||
join issn on issn.id=pd.datasource
|
||||
join gold_oa on issn.issn=gold_oa.issn
|
||||
where (gold_oa.journal_is_in_doaj=false or gold_oa.journal_is_oa=false))tmp
|
||||
on pd.id=tmp.id;
|
||||
select pd.id,coalesce(is_hybrid,0) is_hybrid from ${stats_db_name}.publication_datasources pd
|
||||
left outer join (select pd.id, 1 as is_hybrid from ${stats_db_name}.publication_datasources pd
|
||||
join ${stats_db_name}.datasource d on pd.datasource=d.id
|
||||
join ${stats_db_name}.result_instance ri on ri.id=pd.id
|
||||
join ${stats_db_name}.indi_pub_gold_oa indi_gold on indi_gold.id=pd.id
|
||||
join ${stats_db_name}.result_accessroute ra on ra.id=pd.id
|
||||
where d.type like '%Journal%' and ri.accessright!='Closed Access' and (ri.accessright_uw!='gold'
|
||||
or indi_gold.is_gold=0) and (ra.accessroute='hybrid' or ri.license is not null)) tmp
|
||||
on pd.id=tmp.id;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_org_fairness purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_org_fairness stored as parquet as
|
||||
--return results with PIDs, and rich metadata group by organization
|
||||
|
@ -381,6 +468,8 @@ select ro.organization, count(distinct ro.id) no_allresults from ${stats_db_name
|
|||
where cast(year as int)>2003
|
||||
group by ro.organization;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_org_fairness_pub_pr purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_org_fairness_pub_pr stored as parquet as
|
||||
select ar.organization, rf.no_result_fair/ar.no_allresults org_fairness
|
||||
from ${stats_db_name}.allresults ar
|
||||
|
@ -400,6 +489,8 @@ CREATE TEMPORARY TABLE ${stats_db_name}.allresults as select year, ro.organizati
|
|||
where cast(year as int)>2003
|
||||
group by ro.organization, year;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_org_fairness_pub_year purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_org_fairness_pub_year stored as parquet as
|
||||
select allresults.year, allresults.organization, result_fair.no_result_fair/allresults.no_allresults org_fairness
|
||||
from ${stats_db_name}.allresults
|
||||
|
@ -422,6 +513,8 @@ CREATE TEMPORARY TABLE ${stats_db_name}.allresults as
|
|||
where cast(year as int)>2003
|
||||
group by ro.organization;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_org_fairness_pub purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_org_fairness_pub as
|
||||
select ar.organization, rf.no_result_fair/ar.no_allresults org_fairness
|
||||
from ${stats_db_name}.allresults ar join ${stats_db_name}.result_fair rf
|
||||
|
@ -443,6 +536,8 @@ CREATE TEMPORARY TABLE ${stats_db_name}.allresults as
|
|||
where cast(year as int)>2003
|
||||
group by ro.organization, year;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_org_fairness_year purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_org_fairness_year stored as parquet as
|
||||
select cast(allresults.year as int) year, allresults.organization, result_fair.no_result_fair/allresults.no_allresults org_fairness
|
||||
from ${stats_db_name}.allresults
|
||||
|
@ -464,6 +559,8 @@ CREATE TEMPORARY TABLE ${stats_db_name}.allresults as
|
|||
where cast(year as int) >2003
|
||||
group by ro.organization, year;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_org_findable_year purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_org_findable_year stored as parquet as
|
||||
select cast(allresults.year as int) year, allresults.organization, result_with_pid.no_result_with_pid/allresults.no_allresults org_findable
|
||||
from ${stats_db_name}.allresults
|
||||
|
@ -485,6 +582,8 @@ select ro.organization, count(distinct ro.id) no_allresults from ${stats_db_name
|
|||
where cast(year as int) >2003
|
||||
group by ro.organization;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_org_findable purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_org_findable stored as parquet as
|
||||
select allresults.organization, result_with_pid.no_result_with_pid/allresults.no_allresults org_findable
|
||||
from ${stats_db_name}.allresults
|
||||
|
@ -549,6 +648,8 @@ select software_oa.organization, software_oa.no_oasoftware/allsoftware.no_allsof
|
|||
from ${stats_db_name}.allsoftware
|
||||
join ${stats_db_name}.software_oa on allsoftware.organization=software_oa.organization;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_org_openess purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_org_openess stored as parquet as
|
||||
select allpubsshare.organization,
|
||||
(p+if(isnull(s),0,s)+if(isnull(d),0,d))/(1+(case when s is null then 0 else 1 end)
|
||||
|
@ -624,6 +725,7 @@ select allsoftware.year, software_oa.organization, software_oa.no_oasoftware/all
|
|||
from ${stats_db_name}.allsoftware
|
||||
join ${stats_db_name}.software_oa on allsoftware.organization=software_oa.organization where cast(allsoftware.year as INT)=cast(software_oa.year as int);
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_org_openess_year purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_org_openess_year stored as parquet as
|
||||
select cast(allpubsshare.year as int) year, allpubsshare.organization,
|
||||
|
@ -647,6 +749,8 @@ DROP TABLE ${stats_db_name}.allpubsshare purge;
|
|||
DROP TABLE ${stats_db_name}.alldatasetssshare purge;
|
||||
DROP TABLE ${stats_db_name}.allsoftwaresshare purge;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_pub_has_preprint purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_has_preprint stored as parquet as
|
||||
select distinct p.id, coalesce(has_preprint, 0) as has_preprint
|
||||
from ${stats_db_name}.publication_classifications p
|
||||
|
@ -655,6 +759,7 @@ from ${stats_db_name}.publication_classifications p
|
|||
from ${stats_db_name}.publication_classifications p
|
||||
where p.type='Preprint') tmp
|
||||
on p.id= tmp.id;
|
||||
drop table if exists ${stats_db_name}.indi_pub_in_subscribed purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_in_subscribed stored as parquet as
|
||||
select distinct p.id, coalesce(is_subscription, 0) as is_subscription
|
||||
|
@ -667,6 +772,8 @@ from ${stats_db_name}.publication p
|
|||
where g.is_gold=0 and h.is_hybrid=0 and t.is_transformative=0) tmp
|
||||
on p.id=tmp.id;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_result_with_pid purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_result_with_pid as
|
||||
select distinct p.id, coalesce(result_with_pid, 0) as result_with_pid
|
||||
from ${stats_db_name}.result p
|
||||
|
@ -679,6 +786,8 @@ CREATE TEMPORARY TABLE ${stats_db_name}.pub_fos_totals as
|
|||
select rf.id, count(distinct lvl3) totals from ${stats_db_name}.result_fos rf
|
||||
group by rf.id;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_pub_interdisciplinarity purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_interdisciplinarity as
|
||||
select distinct p.id as id, coalesce(is_interdisciplinary, 0)
|
||||
as is_interdisciplinary
|
||||
|
@ -689,18 +798,31 @@ where totals>1) tmp on p.id=tmp.id;
|
|||
|
||||
drop table ${stats_db_name}.pub_fos_totals purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_pub_bronze_oa stored as parquet as
|
||||
select distinct p.id, coalesce(is_bronze_oa,0) as is_bronze_oa
|
||||
from ${stats_db_name}.publication p
|
||||
left outer join
|
||||
(select p.id, 1 as is_bronze_oa from ${stats_db_name}.publication p
|
||||
join ${stats_db_name}.indi_result_has_cc_licence cc on cc.id=p.id
|
||||
join ${stats_db_name}.indi_pub_gold_oa ga on ga.id=p.id
|
||||
join ${stats_db_name}.result_instance ri on ri.id=p.id
|
||||
join ${stats_db_name}.datasource d on d.id=ri.hostedby
|
||||
where cc.has_cc_license=0 and ga.is_gold=0
|
||||
and (d.type='Journal' or d.type='Journal Aggregator/Publisher')
|
||||
and ri.accessright='Open Access') tmp on tmp.id=p.id;
|
||||
drop table if exists ${stats_db_name}.indi_pub_bronze_oa purge;
|
||||
|
||||
--create table if not exists ${stats_db_name}.indi_pub_bronze_oa stored as parquet as
|
||||
--select distinct p.id, coalesce(is_bronze_oa,0) as is_bronze_oa
|
||||
--from ${stats_db_name}.publication p
|
||||
--left outer join
|
||||
--(select p.id, 1 as is_bronze_oa from ${stats_db_name}.publication p
|
||||
--join ${stats_db_name}.indi_result_has_cc_licence cc on cc.id=p.id
|
||||
--join ${stats_db_name}.indi_pub_gold_oa ga on ga.id=p.id
|
||||
--join ${stats_db_name}.result_instance ri on ri.id=p.id
|
||||
--join ${stats_db_name}.datasource d on d.id=ri.hostedby
|
||||
--where cc.has_cc_license=0 and ga.is_gold=0
|
||||
--and (d.type='Journal' or d.type='Journal Aggregator/Publisher')
|
||||
--and ri.accessright='Open Access') tmp on tmp.id=p.id;
|
||||
|
||||
create table ${stats_db_name}.indi_pub_bronze stored as parquet as
|
||||
select pd.id,coalesce(is_bronze_oa,0) is_bronze_oa from ${stats_db_name}.publication_datasources pd
|
||||
left outer join (select pd.id, 1 as is_bronze_oa from ${stats_db_name}.publication_datasources pd
|
||||
join ${stats_db_name}.datasource d on pd.datasource=d.id
|
||||
join ${stats_db_name}.result_instance ri on ri.id=pd.id
|
||||
join ${stats_db_name}.indi_pub_gold_oa indi_gold on indi_gold.id=pd.id
|
||||
join ${stats_db_name}.result_accessroute ra on ra.id=pd.id
|
||||
where d.type like '%Journal%' and ri.accessright!='Closed Access' and (ri.accessright_uw!='gold'
|
||||
or indi_gold.is_gold=0) and (ra.accessroute='bronze' or ri.license is null)) tmp
|
||||
on pd.id=tmp.id;
|
||||
|
||||
CREATE TEMPORARY TABLE ${stats_db_name}.project_year_result_year as
|
||||
select p.id project_id, acronym, r.id result_id, r.year, p.end_year
|
||||
|
@ -709,6 +831,8 @@ join ${stats_db_name}.result_projects rp on p.id=rp.project
|
|||
join ${stats_db_name}.result r on r.id=rp.id
|
||||
where p.end_year is NOT NULL and r.year is not null;
|
||||
|
||||
drop table if exists ${stats_db_name}.indi_is_project_result_after purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_is_project_result_after stored as parquet as
|
||||
select pry.project_id, pry.acronym, pry.result_id,
|
||||
coalesce(is_project_result_after, 0) as is_project_result_after
|
||||
|
@ -719,6 +843,8 @@ where pry.year>pry.end_year) tmp on pry.result_id=tmp.result_id;
|
|||
|
||||
drop table ${stats_db_name}.project_year_result_year purge;
|
||||
|
||||
drop table ${stats_db_name}.indi_is_funder_plan_s purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_is_funder_plan_s stored as parquet as
|
||||
select distinct f.id, f.name, coalesce(is_funder_plan_s, 0) as is_funder_plan_s
|
||||
from ${stats_db_name}.funder f
|
||||
|
@ -727,6 +853,7 @@ from ${stats_db_name}.funder f
|
|||
on f.name= tmp.name;
|
||||
|
||||
--Funder Fairness
|
||||
drop table ${stats_db_name}.indi_funder_fairness purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_funder_fairness stored as parquet as
|
||||
with result_fair as
|
||||
|
@ -745,6 +872,8 @@ from allresults
|
|||
join result_fair on result_fair.funder=allresults.funder;
|
||||
|
||||
--RIs Fairness
|
||||
drop table ${stats_db_name}.indi_ris_fairness purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_ris_fairness stored as parquet as
|
||||
with result_contexts as
|
||||
(select distinct rc.id, context.name ri_initiative from ${stats_db_name}.result_concepts rc
|
||||
|
@ -830,6 +959,8 @@ select software_oa.funder, software_oa.no_oasoftware/allsoftware.no_allsoftware
|
|||
from ${stats_db_name}.allsoftware
|
||||
join ${stats_db_name}.software_oa on allsoftware.funder=software_oa.funder;
|
||||
|
||||
drop table ${stats_db_name}.indi_funder_openess purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_funder_openess stored as parquet as
|
||||
select allpubsshare.funder,
|
||||
(p+if(isnull(s),0,s)+if(isnull(d),0,d))/(1+(case when s is null then 0 else 1 end)
|
||||
|
@ -916,6 +1047,8 @@ select software_oa.ri_initiative, software_oa.no_oasoftware/allsoftware.no_allso
|
|||
from ${stats_db_name}.allsoftware
|
||||
join ${stats_db_name}.software_oa on allsoftware.ri_initiative=software_oa.ri_initiative;
|
||||
|
||||
drop table ${stats_db_name}.indi_ris_openess purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_ris_openess stored as parquet as
|
||||
select allpubsshare.ri_initiative,
|
||||
(p+if(isnull(s),0,s)+if(isnull(d),0,d))/(1+(case when s is null then 0 else 1 end)
|
||||
|
@ -940,6 +1073,8 @@ DROP TABLE ${stats_db_name}.alldatasetssshare purge;
|
|||
DROP TABLE ${stats_db_name}.allsoftwaresshare purge;
|
||||
|
||||
--Funder Findability
|
||||
drop table ${stats_db_name}.indi_funder_findable purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_funder_findable stored as parquet as
|
||||
with result_findable as
|
||||
(select p.funder funder, count(distinct rp.id) no_result_findable from ${stats_db_name}.result_projects rp
|
||||
|
@ -958,6 +1093,8 @@ from allresults
|
|||
join result_findable on result_findable.funder=allresults.funder;
|
||||
|
||||
--RIs Findability
|
||||
drop table ${stats_db_name}.indi_ris_findable purge;
|
||||
|
||||
create table if not exists ${stats_db_name}.indi_ris_findable stored as parquet as
|
||||
with result_contexts as
|
||||
(select distinct rc.id, context.name ri_initiative from ${stats_db_name}.result_concepts rc
|
||||
|
|
Loading…
Reference in New Issue