Changes in indicators step, monitor step

- graduatedoctorates for observatory
- result_apc_affiliations table
- new indicators
	indi_is_funder_plan_s
	indi_funder_fairness
	indi_ris_fairness
	indi_funder_openess
	indi_ris_openess
	indi_funder_findable
	indi_ris_findable
	indi_is_project_result_after
- cast year to int in composite indicators
- new institutions
     -- Universidade Católica Portuguesa
     -- Iscte - Instituto Universitário de Lisboa
     -- Munster Technological University
     -- Cardiff University
     -- Leibniz Institute of Ecological Urban and Regional Development
This commit is contained in:
dimitrispie 2023-09-01 10:57:02 +03:00
parent be4856ef35
commit 964c2f553e
10 changed files with 324 additions and 93 deletions

View File

@ -39,7 +39,7 @@ hdfs dfs -copyToLocal $9
echo "Creating monitor database"
cat step20-createMonitorDBAll.sql | sed "s/SOURCE/openaire_prod_stats_20230707/g" | sed "s/TARGET/openaire_prod_stats_monitor_20230707/g1" > foo
cat step20-createMonitorDBAll.sql | sed "s/SOURCE/$1/g" | sed "s/TARGET/$2/g1" > foo
hive $HIVE_OPTS -f foo
cat step20-createMonitorDB_funded.sql | sed "s/SOURCE/$1/g" | sed "s/TARGET/$2_funded/g1" > foo

View File

@ -48,4 +48,4 @@ rel.properties[1].value apc_currency
from ${openaire_db_name}.relation rel
join ${openaire_db_name}.organization o on o.id=rel.source
join ${openaire_db_name}.result r on r.id=rel.target
where rel.subreltype = 'affiliation' and rel.datainfo.deletedbyinference = false and size(rel.properties) > 0;
where rel.subreltype = 'affiliation' and rel.datainfo.deletedbyinference = false and size(rel.properties)>0;

View File

@ -35,6 +35,7 @@ create or replace view ${stats_db_name}.doctoratestudents as select * from stats
create or replace view ${stats_db_name}.totalresearchers as select * from stats_ext.totalresearchers;
create or replace view ${stats_db_name}.totalresearchersft as select * from stats_ext.totalresearchersft;
create or replace view ${stats_db_name}.hrrst as select * from stats_ext.hrrst;
create or replace view ${stats_db_name}.graduatedoctorates as select * from stats_ext.graduatedoctorates;
create table if not exists ${stats_db_name}.result_instance stored as parquet as
select distinct r.*

View File

@ -12,8 +12,6 @@ from ${stats_db_name}.publication p
or ri.accessright = 'Embargo' or ri.accessright = 'Open Source')) tmp
on p.id= tmp.id;
--ANALYZE TABLE ${stats_db_name}.indi_pub_green_oa COMPUTE STATISTICS;
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
@ -25,8 +23,6 @@ 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;
--ANALYZE TABLE ${stats_db_name}.indi_pub_grey_lit COMPUTE STATISTICS;
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
@ -36,8 +32,6 @@ from ${stats_db_name}.publication p
where pidtype='Digital Object Identifier' and d.name ='Crossref') tmp
on tmp.id=p.id;
--ANALYZE TABLE ${stats_db_name}.indi_pub_doi_from_crossref COMPUTE STATISTICS;
-- Sprint 2 ----
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
@ -47,8 +41,6 @@ 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;
--ANALYZE TABLE ${stats_db_name}.indi_result_has_cc_licence COMPUTE STATISTICS;
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
@ -58,22 +50,16 @@ from ${stats_db_name}.result r
WHERE lower(parse_url(license.type, "HOST")) = "creativecommons.org") tmp
on r.id= tmp.id;
--ANALYZE TABLE ${stats_db_name}.indi_result_has_cc_licence_url COMPUTE STATISTICS;
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;
--ANALYZE TABLE ${stats_db_name}.indi_pub_has_abstract COMPUTE STATISTICS;
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
left outer join (select id, 1 as has_orcid from ${stats_db_name}.result_orcid) tmp
on r.id= tmp.id;
--ANALYZE TABLE ${stats_db_name}.indi_result_with_orcid COMPUTE STATISTICS;
---- Sprint 3 ----
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
@ -82,8 +68,6 @@ from ${stats_db_name}.project_results r
where provenance='Harvested') tmp
on r.result= tmp.result;
--ANALYZE TABLE ${stats_db_name}.indi_funded_result_with_fundref COMPUTE STATISTICS;
-- create table indi_result_org_collab stored as parquet as
-- select o1.organization org1, o2.organization org2, count(distinct o1.id) as collaborations
-- from result_organization as o1
@ -103,8 +87,6 @@ group by o1.organization, o2.organization, o1.name, o2.name;
drop table ${stats_db_name}.tmp purge;
--ANALYZE TABLE ${stats_db_name}.indi_result_org_collab COMPUTE STATISTICS;
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;
@ -117,8 +99,6 @@ group by o1.organization, o1.id, o1.name, o2.country;
drop table ${stats_db_name}.tmp purge;
--ANALYZE TABLE ${stats_db_name}.indi_result_org_country_collab COMPUTE STATISTICS;
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;
@ -132,8 +112,6 @@ group by o1.name,o2.name, o1.organization, o2.organization;
drop table ${stats_db_name}.tmp purge;
--ANALYZE TABLE ${stats_db_name}.indi_project_collab_org COMPUTE STATISTICS;
create TEMPORARY TABLE ${stats_db_name}.tmp AS
select o.id organization, o.name, o.country , ro.project as project from ${stats_db_name}.organization o
join ${stats_db_name}.organization_projects ro on o.id=ro.id
@ -148,8 +126,6 @@ group by o1.organization, o2.country, o1.name;
drop table ${stats_db_name}.tmp purge;
--ANALYZE TABLE ${stats_db_name}.indi_project_collab_org_country COMPUTE STATISTICS;
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
@ -161,8 +137,6 @@ from tmp as f1
where f1.country<>f2.country
group by f1.funder, f2.country, f1.country;
--ANALYZE TABLE ${stats_db_name}.indi_funder_country_collab COMPUTE STATISTICS;
create TEMPORARY TABLE ${stats_db_name}.tmp AS
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
@ -177,8 +151,6 @@ group by o1.country, o2.country;
drop table ${stats_db_name}.tmp purge;
--ANALYZE TABLE ${stats_db_name}.indi_result_country_collab COMPUTE STATISTICS;
---- Sprint 4 ----
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
@ -190,8 +162,6 @@ 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;
----ANALYZE TABLE ${stats_db_name}.indi_pub_diamond COMPUTE STATISTICS;
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
@ -202,8 +172,6 @@ from ${stats_db_name}.publication pd
and ps.is_transformative_journal=true) tmp
on pd.id=tmp.id;
--ANALYZE TABLE ${stats_db_name}.indi_pub_in_transformative COMPUTE STATISTICS;
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
@ -214,14 +182,10 @@ select distinct ri.id, coalesce(pub_closed_other_open, 0) as pub_closed_other_op
(p.bestlicence='Open Access' or p.bestlicence='Open Source')) tmp
on tmp.id=ri.id;
--ANALYZE TABLE ${stats_db_name}.indi_pub_closed_other_open COMPUTE STATISTICS;
---- Sprint 5 ----
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;
--ANALYZE TABLE ${stats_db_name}.indi_result_no_of_copies COMPUTE STATISTICS;
---- Sprint 6 ----
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
@ -239,24 +203,18 @@ where downloads>0
GROUP BY result_id, repository_id
order by result_id;
--ANALYZE TABLE ${stats_db_name}.indi_pub_downloads_datasource COMPUTE STATISTICS;
create table if not exists ${stats_db_name}.indi_pub_downloads_year stored as parquet as
SELECT result_id, substring(us.`date`, 1,4) as `year`, sum(downloads) no_downloads
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);
--ANALYZE TABLE ${stats_db_name}.indi_pub_downloads_year COMPUTE STATISTICS;
create table if not exists ${stats_db_name}.indi_pub_downloads_datasource_year stored as parquet as
SELECT result_id, substring(us.`date`, 1,4) as `year`, repository_id, sum(downloads) no_downloads from openaire_prod_usage_stats.usage_stats us
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
where downloads>0
GROUP BY result_id, repository_id, substring(us.`date`, 1,4);
--ANALYZE TABLE ${stats_db_name}.indi_pub_downloads_datasource_year COMPUTE STATISTICS;
---- Sprint 7 ----
create table if not exists ${stats_db_name}.indi_pub_gold_oa stored as parquet as
WITH gold_oa AS ( SELECT
@ -307,8 +265,6 @@ FROM
JOIN gold_oa on issn.issn = gold_oa.issn) tmp
on pd.id=tmp.id;
--ANALYZE TABLE ${stats_db_name}.indi_pub_gold_oa COMPUTE STATISTICS;
create table if not exists ${stats_db_name}.indi_pub_hybrid_oa_with_cc stored as parquet as
WITH hybrid_oa AS (
SELECT issn_l, journal_is_in_doaj, journal_is_oa, issn_print as issn
@ -340,8 +296,6 @@ 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;
--ANALYZE TABLE ${stats_db_name}.indi_pub_hybrid_oa_with_cc COMPUTE STATISTICS;
create table if not exists ${stats_db_name}.indi_pub_hybrid stored as parquet as
WITH gold_oa AS ( SELECT
issn_l,
@ -393,8 +347,6 @@ from ${stats_db_name}.publication_datasources pd
where (gold_oa.journal_is_in_doaj=false or gold_oa.journal_is_oa=false))tmp
on pd.id=tmp.id;
--ANALYZE TABLE ${stats_db_name}.indi_pub_hybrid COMPUTE STATISTICS;
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
with result_fair as
@ -413,8 +365,6 @@ select allresults.organization, result_fair.no_result_fair/allresults.no_allresu
from allresults
join result_fair on result_fair.organization=allresults.organization;
--ANALYZE TABLE ${stats_db_name}.indi_org_fairness COMPUTE STATISTICS;
CREATE TEMPORARY table ${stats_db_name}.result_fair as
select ro.organization organization, count(distinct ro.id) no_result_fair
from ${stats_db_name}.result_organization ro
@ -439,8 +389,6 @@ from ${stats_db_name}.allresults ar
DROP table ${stats_db_name}.result_fair purge;
DROP table ${stats_db_name}.allresults purge;
--ANALYZE TABLE ${stats_db_name}.indi_org_fairness_pub_pr COMPUTE STATISTICS;
CREATE TEMPORARY table ${stats_db_name}.result_fair as
select year, ro.organization organization, count(distinct ro.id) no_result_fair from ${stats_db_name}.result_organization ro
join ${stats_db_name}.result p on p.id=ro.id
@ -460,8 +408,6 @@ from ${stats_db_name}.allresults
DROP table ${stats_db_name}.result_fair purge;
DROP table ${stats_db_name}.allresults purge;
--ANALYZE TABLE ${stats_db_name}.indi_org_fairness_pub_year COMPUTE STATISTICS;
CREATE TEMPORARY TABLE ${stats_db_name}.result_fair as
select ro.organization organization, count(distinct ro.id) no_result_fair
from ${stats_db_name}.result_organization ro
@ -484,8 +430,6 @@ on rf.organization=ar.organization;
DROP table ${stats_db_name}.result_fair purge;
DROP table ${stats_db_name}.allresults purge;
--ANALYZE TABLE ${stats_db_name}.indi_org_fairness_pub COMPUTE STATISTICS;
CREATE TEMPORARY TABLE ${stats_db_name}.result_fair as
select year, ro.organization organization, count(distinct ro.id) no_result_fair from ${stats_db_name}.result_organization ro
join ${stats_db_name}.result r on r.id=ro.id
@ -507,8 +451,6 @@ create table if not exists ${stats_db_name}.indi_org_fairness_year stored as par
DROP table ${stats_db_name}.result_fair purge;
DROP table ${stats_db_name}.allresults purge;
--ANALYZE TABLE ${stats_db_name}.indi_org_fairness_year COMPUTE STATISTICS;
CREATE TEMPORARY TABLE ${stats_db_name}.result_with_pid as
select year, ro.organization, count(distinct rp.id) no_result_with_pid from ${stats_db_name}.result_organization ro
join ${stats_db_name}.result_pids rp on rp.id=ro.id
@ -530,8 +472,6 @@ from ${stats_db_name}.allresults
DROP table ${stats_db_name}.result_with_pid purge;
DROP table ${stats_db_name}.allresults purge;
--ANALYZE TABLE ${stats_db_name}.indi_org_findable_year COMPUTE STATISTICS;
CREATE TEMPORARY TABLE ${stats_db_name}.result_with_pid as
select ro.organization, count(distinct rp.id) no_result_with_pid from ${stats_db_name}.result_organization ro
join ${stats_db_name}.result_pids rp on rp.id=ro.id
@ -553,8 +493,6 @@ from ${stats_db_name}.allresults
DROP table ${stats_db_name}.result_with_pid purge;
DROP table ${stats_db_name}.allresults purge;
--ANALYZE TABLE ${stats_db_name}.indi_org_findable COMPUTE STATISTICS;
CREATE TEMPORARY TABLE ${stats_db_name}.pubs_oa as
SELECT ro.organization, count(distinct r.id) no_oapubs FROM ${stats_db_name}.publication r
join ${stats_db_name}.result_organization ro on ro.id=r.id
@ -633,8 +571,6 @@ DROP TABLE ${stats_db_name}.allpubsshare purge;
DROP TABLE ${stats_db_name}.alldatasetssshare purge;
DROP TABLE ${stats_db_name}.allsoftwaresshare purge;
--ANALYZE TABLE ${stats_db_name}.indi_org_openess COMPUTE STATISTICS;
CREATE TEMPORARY TABLE ${stats_db_name}.pubs_oa AS
SELECT r.year, ro.organization, count(distinct r.id) no_oapubs FROM ${stats_db_name}.publication r
join ${stats_db_name}.result_organization ro on ro.id=r.id
@ -690,7 +626,7 @@ select allsoftware.year, software_oa.organization, software_oa.no_oasoftware/all
create table if not exists ${stats_db_name}.indi_org_openess_year stored as parquet as
select allpubsshare.year, allpubsshare.organization,
select cast(allpubsshare.year as int), allpubsshare.organization,
(p+if(isnull(s),0,s)+if(isnull(d),0,d))/(1+(case when s is null then 0 else 1 end)
+(case when d is null then 0 else 1 end))
org_openess FROM ${stats_db_name}.allpubsshare
@ -711,8 +647,6 @@ DROP TABLE ${stats_db_name}.allpubsshare purge;
DROP TABLE ${stats_db_name}.alldatasetssshare purge;
DROP TABLE ${stats_db_name}.allsoftwaresshare purge;
--ANALYZE TABLE ${stats_db_name}.indi_org_openess_year COMPUTE STATISTICS;
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
@ -722,8 +656,6 @@ from ${stats_db_name}.publication_classifications p
where p.type='Preprint') tmp
on p.id= tmp.id;
--ANALYZE TABLE ${stats_db_name}.indi_pub_has_preprint COMPUTE STATISTICS;
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
from ${stats_db_name}.publication p
@ -735,8 +667,6 @@ 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;
--ANALYZE TABLE ${stats_db_name}.indi_pub_in_subscribed COMPUTE STATISTICS;
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
@ -745,8 +675,6 @@ from ${stats_db_name}.result p
from ${stats_db_name}.result_pids p) tmp
on p.id= tmp.id;
--ANALYZE TABLE ${stats_db_name}.indi_result_with_pid COMPUTE STATISTICS;
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;
@ -761,8 +689,6 @@ where totals>1) tmp on p.id=tmp.id;
drop table ${stats_db_name}.pub_fos_totals purge;
--ANALYZE TABLE ${stats_db_name}.indi_pub_interdisciplinarity COMPUTE STATISTICS;
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
@ -772,4 +698,280 @@ 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
where cc.has_cc_license=0 and ga.is_gold=0) tmp on tmp.id=p.id;
--ANALYZE TABLE ${stats_db_name}.indi_pub_bronze_oa COMPUTE STATISTICS;
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
from ${stats_db_name}.project p
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;
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
from ${stats_db_name}.project_year_result_year pry
left outer join (select pry.project_id, pry.acronym, pry.result_id, 1 as is_project_result_after
from ${stats_db_name}.project_year_result_year pry
where pry.year>pry.end_year) tmp on pry.result_id=tmp.result_id;
drop table ${stats_db_name}.project_year_result_year 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
left outer join (select id, name, 1 as is_funder_plan_s from ${stats_db_name}.funder
join stats_ext.plan_s_short on c_o_alition_s_organisation_funder=name) tmp
on f.name= tmp.name;
--Funder Fairness
create table if not exists ${stats_db_name}.indi_funder_fairness stored as parquet as
with result_fair as
(select p.funder funder, count(distinct rp.id) no_result_fair from ${stats_db_name}.result_projects rp
join ${stats_db_name}.result r on r.id=rp.id
join ${stats_db_name}.project p on p.id=rp.project
where (r.title is not null) and (publisher is not null) and (abstract=true) and (year is not null) and (authors>0) and cast(year as int)>2003
group by p.funder),
allresults as (select p.funder funder, count(distinct rp.id) no_allresults from ${stats_db_name}.result_projects rp
join ${stats_db_name}.result r on r.id=rp.id
join ${stats_db_name}.project p on p.id=rp.project
where cast(year as int)>2003
group by p.funder)
select allresults.funder, result_fair.no_result_fair/allresults.no_allresults funder_fairness
from allresults
join result_fair on result_fair.funder=allresults.funder;
--RIs Fairness
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
join ${stats_db_name}.concept on concept.id=rc.concept
join ${stats_db_name}.category on category.id=concept.category
join ${stats_db_name}.context on context.id=category.context),
result_fair as
(select rc.ri_initiative ri_initiative, count(distinct rc.id) no_result_fair from result_contexts rc
join ${stats_db_name}.result r on r.id=rc.id
where (title is not null) and (publisher is not null) and (abstract=true) and (year is not null) and (authors>0) and cast(year as int)>2003
group by rc.ri_initiative),
allresults as
(select rc.ri_initiative ri_initiative, count(distinct rc.id) no_allresults from result_contexts rc
join ${stats_db_name}.result r on r.id=rc.id
where cast(year as int)>2003
group by rc.ri_initiative)
select allresults.ri_initiative, result_fair.no_result_fair/allresults.no_allresults ris_fairness
from allresults
join result_fair on result_fair.ri_initiative=allresults.ri_initiative;
--Funder Openess
CREATE TEMPORARY TABLE ${stats_db_name}.pubs_oa as
select p.funder funder, count(distinct rp.id) no_oapubs from ${stats_db_name}.result_projects rp
join ${stats_db_name}.project p on p.id=rp.project
join ${stats_db_name}.publication r on r.id=rp.id
join ${stats_db_name}.result_instance ri on ri.id=r.id
where (ri.accessright = 'Open Access' or ri.accessright = 'Embargo' or ri.accessright = 'Open Source')
and cast(r.year as int)>2003
group by p.funder;
CREATE TEMPORARY TABLE ${stats_db_name}.datasets_oa as
select p.funder funder, count(distinct rp.id) no_oadatasets from ${stats_db_name}.result_projects rp
join ${stats_db_name}.project p on p.id=rp.project
join ${stats_db_name}.dataset r on r.id=rp.id
join ${stats_db_name}.result_instance ri on ri.id=r.id
where (ri.accessright = 'Open Access' or ri.accessright = 'Embargo' or ri.accessright = 'Open Source')
and cast(r.year as int)>2003
group by p.funder;
CREATE TEMPORARY TABLE ${stats_db_name}.software_oa as
select p.funder funder, count(distinct rp.id) no_oasoftware from ${stats_db_name}.result_projects rp
join ${stats_db_name}.project p on p.id=rp.project
join ${stats_db_name}.software r on r.id=rp.id
join ${stats_db_name}.result_instance ri on ri.id=r.id
where (ri.accessright = 'Open Access' or ri.accessright = 'Embargo' or ri.accessright = 'Open Source')
and cast(r.year as int)>2003
group by p.funder;
CREATE TEMPORARY TABLE ${stats_db_name}.allpubs as
select p.funder funder, count(distinct rp.id) no_allpubs from ${stats_db_name}.result_projects rp
join ${stats_db_name}.project p on p.id=rp.project
join ${stats_db_name}.publication r on r.id=rp.id
where cast(r.year as int)>2003
group by p.funder;
CREATE TEMPORARY TABLE ${stats_db_name}.alldatasets as
select p.funder funder, count(distinct rp.id) no_alldatasets from ${stats_db_name}.result_projects rp
join ${stats_db_name}.project p on p.id=rp.project
join ${stats_db_name}.dataset r on r.id=rp.id
where cast(r.year as int)>2003
group by p.funder;
CREATE TEMPORARY TABLE ${stats_db_name}.allsoftware as
select p.funder funder, count(distinct rp.id) no_allsoftware from ${stats_db_name}.result_projects rp
join ${stats_db_name}.project p on p.id=rp.project
join ${stats_db_name}.software r on r.id=rp.id
where cast(r.year as int)>2003
group by p.funder;
CREATE TEMPORARY TABLE ${stats_db_name}.allpubsshare as
select pubs_oa.funder, pubs_oa.no_oapubs/allpubs.no_allpubs p from ${stats_db_name}.allpubs
join ${stats_db_name}.pubs_oa on allpubs.funder=pubs_oa.funder;
CREATE TEMPORARY TABLE ${stats_db_name}.alldatasetssshare as
select datasets_oa.funder, datasets_oa.no_oadatasets/alldatasets.no_alldatasets d
from ${stats_db_name}.alldatasets
join ${stats_db_name}.datasets_oa on alldatasets.funder=datasets_oa.funder;
CREATE TEMPORARY TABLE ${stats_db_name}.allsoftwaresshare as
select software_oa.funder, software_oa.no_oasoftware/allsoftware.no_allsoftware s
from ${stats_db_name}.allsoftware
join ${stats_db_name}.software_oa on allsoftware.funder=software_oa.funder;
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)
+(case when d is null then 0 else 1 end))
funder_openess FROM ${stats_db_name}.allpubsshare
left outer join (select funder,d from
${stats_db_name}.alldatasetssshare) tmp1
on tmp1.funder=allpubsshare.funder
left outer join (select funder,s from
${stats_db_name}.allsoftwaresshare) tmp2
on tmp2.funder=allpubsshare.funder;
DROP TABLE ${stats_db_name}.pubs_oa purge;
DROP TABLE ${stats_db_name}.datasets_oa purge;
DROP TABLE ${stats_db_name}.software_oa purge;
DROP TABLE ${stats_db_name}.allpubs purge;
DROP TABLE ${stats_db_name}.alldatasets purge;
DROP TABLE ${stats_db_name}.allsoftware purge;
DROP TABLE ${stats_db_name}.allpubsshare purge;
DROP TABLE ${stats_db_name}.alldatasetssshare purge;
DROP TABLE ${stats_db_name}.allsoftwaresshare purge;
--RIs Openess
CREATE TEMPORARY TABLE ${stats_db_name}.result_contexts as
select distinct rc.id, context.name ri_initiative from ${stats_db_name}.result_concepts rc
join ${stats_db_name}.concept on concept.id=rc.concept
join ${stats_db_name}.category on category.id=concept.category
join ${stats_db_name}.context on context.id=category.context;
CREATE TEMPORARY TABLE ${stats_db_name}.pubs_oa as
select rp.ri_initiative ri_initiative, count(distinct rp.id) no_oapubs from ${stats_db_name}.result_contexts rp
join ${stats_db_name}.publication r on r.id=rp.id
join ${stats_db_name}.result_instance ri on ri.id=r.id
where (ri.accessright = 'Open Access' or ri.accessright = 'Embargo' or ri.accessright = 'Open Source')
and cast(r.year as int)>2003
group by rp.ri_initiative;
CREATE TEMPORARY TABLE ${stats_db_name}.datasets_oa as
select rp.ri_initiative ri_initiative, count(distinct rp.id) no_oadatasets from ${stats_db_name}.result_contexts rp
join ${stats_db_name}.dataset r on r.id=rp.id
join ${stats_db_name}.result_instance ri on ri.id=r.id
where (ri.accessright = 'Open Access' or ri.accessright = 'Embargo' or ri.accessright = 'Open Source')
and cast(r.year as int)>2003
group by rp.ri_initiative;
CREATE TEMPORARY TABLE ${stats_db_name}.software_oa as
select rp.ri_initiative ri_initiative, count(distinct rp.id) no_oasoftware from ${stats_db_name}.result_contexts rp
join ${stats_db_name}.software r on r.id=rp.id
join ${stats_db_name}.result_instance ri on ri.id=r.id
where (ri.accessright = 'Open Access' or ri.accessright = 'Embargo' or ri.accessright = 'Open Source')
and cast(r.year as int)>2003
group by rp.ri_initiative;
CREATE TEMPORARY TABLE ${stats_db_name}.allpubs as
select rp.ri_initiative ri_initiative, count(distinct rp.id) no_allpubs from ${stats_db_name}.result_contexts rp
join ${stats_db_name}.publication r on r.id=rp.id
where cast(r.year as int)>2003
group by rp.ri_initiative;
CREATE TEMPORARY TABLE ${stats_db_name}.alldatasets as
select rp.ri_initiative ri_initiative, count(distinct rp.id) no_alldatasets from ${stats_db_name}.result_contexts rp
join ${stats_db_name}.dataset r on r.id=rp.id
where cast(r.year as int)>2003
group by rp.ri_initiative;
CREATE TEMPORARY TABLE ${stats_db_name}.allsoftware as
select rp.ri_initiative ri_initiative, count(distinct rp.id) no_allsoftware from ${stats_db_name}.result_contexts rp
join ${stats_db_name}.software r on r.id=rp.id
where cast(r.year as int)>2003
group by rp.ri_initiative;
CREATE TEMPORARY TABLE ${stats_db_name}.allpubsshare as
select pubs_oa.ri_initiative, pubs_oa.no_oapubs/allpubs.no_allpubs p from ${stats_db_name}.allpubs
join ${stats_db_name}.pubs_oa on allpubs.ri_initiative=pubs_oa.ri_initiative;
CREATE TEMPORARY TABLE ${stats_db_name}.alldatasetssshare as
select datasets_oa.ri_initiative, datasets_oa.no_oadatasets/alldatasets.no_alldatasets d
from ${stats_db_name}.alldatasets
join ${stats_db_name}.datasets_oa on alldatasets.ri_initiative=datasets_oa.ri_initiative;
CREATE TEMPORARY TABLE ${stats_db_name}.allsoftwaresshare as
select software_oa.ri_initiative, software_oa.no_oasoftware/allsoftware.no_allsoftware s
from ${stats_db_name}.allsoftware
join ${stats_db_name}.software_oa on allsoftware.ri_initiative=software_oa.ri_initiative;
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)
+(case when d is null then 0 else 1 end))
ris_openess FROM ${stats_db_name}.allpubsshare
left outer join (select ri_initiative,d from
${stats_db_name}.alldatasetssshare) tmp1
on tmp1.ri_initiative=allpubsshare.ri_initiative
left outer join (select ri_initiative,s from
${stats_db_name}.allsoftwaresshare) tmp2
on tmp2.ri_initiative=allpubsshare.ri_initiative;
DROP TABLE ${stats_db_name}.result_contexts purge;
DROP TABLE ${stats_db_name}.pubs_oa purge;
DROP TABLE ${stats_db_name}.datasets_oa purge;
DROP TABLE ${stats_db_name}.software_oa purge;
DROP TABLE ${stats_db_name}.allpubs purge;
DROP TABLE ${stats_db_name}.alldatasets purge;
DROP TABLE ${stats_db_name}.allsoftware purge;
DROP TABLE ${stats_db_name}.allpubsshare purge;
DROP TABLE ${stats_db_name}.alldatasetssshare purge;
DROP TABLE ${stats_db_name}.allsoftwaresshare purge;
--Funder Findability
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
join ${stats_db_name}.publication r on r.id=rp.id
join ${stats_db_name}.project p on p.id=rp.project
join ${stats_db_name}.result_pids rpi on rpi.id=r.id
where cast(year as int)>2003
group by p.funder),
allresults as (select p.funder funder, count(distinct rp.id) no_allresults from ${stats_db_name}.result_projects rp
join ${stats_db_name}.result r on r.id=rp.id
join ${stats_db_name}.project p on p.id=rp.project
where cast(year as int)>2003
group by p.funder)
select allresults.funder, result_findable.no_result_findable/allresults.no_allresults funder_findable
from allresults
join result_findable on result_findable.funder=allresults.funder;
--RIs Findability
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
join ${stats_db_name}.concept on concept.id=rc.concept
join ${stats_db_name}.category on category.id=concept.category
join ${stats_db_name}.context on context.id=category.context),
result_findable as
(select rc.ri_initiative ri_initiative, count(distinct rc.id) no_result_findable from result_contexts rc
join ${stats_db_name}.result r on r.id=rc.id
join ${stats_db_name}.result_pids rp on rp.id=r.id
where cast(r.year as int)>2003
group by rc.ri_initiative),
allresults as
(select rc.ri_initiative ri_initiative, count(distinct rc.id) no_allresults from result_contexts rc
join ${stats_db_name}.result r on r.id=rc.id
where cast(r.year as int)>2003
group by rc.ri_initiative)
select allresults.ri_initiative, result_findable.no_result_findable/allresults.no_allresults ris_findable
from allresults
join result_findable on result_findable.ri_initiative=allresults.ri_initiative;

View File

@ -88,6 +88,7 @@ create view if not exists TARGET.doctoratestudents as select * from SOURCE.docto
create view if not exists TARGET.totalresearchers as select * from SOURCE.totalresearchers;
create view if not exists TARGET.totalresearchersft as select * from SOURCE.totalresearchersft;
create view if not exists TARGET.hrrst as select * from SOURCE.hrrst;
create view if not exists TARGET.graduatedoctorates as select * from SOURCE.graduatedoctorates;
create table TARGET.result_citations stored as parquet as select * from SOURCE.result_citations orig where exists (select 1 from TARGET.result r where r.id=orig.id);
--ANALYZE TABLE TARGET.result_citations COMPUTE STATISTICS;
@ -270,3 +271,11 @@ create table TARGET.indi_pub_interdisciplinarity stored as parquet as select * f
--ANALYZE TABLE TARGET.indi_pub_interdisciplinarity COMPUTE STATISTICS;
create table TARGET.result_apc_affiliations stored as parquet as select * from SOURCE.result_apc_affiliations orig where exists (select 1 from TARGET.result r where r.id=orig.id);
--ANALYZE TABLE TARGET.result_apc_affiliations COMPUTE STATISTICS;
create table TARGET.indi_is_project_result_after stored as parquet as select * from SOURCE.indi_is_project_result_after orig where exists (select 1 from TARGET.result r where r.id=orig.result_id);
create table TARGET.indi_is_funder_plan_s stored as parquet as select * from SOURCE.indi_is_funder_plan_s orig where exists (select 1 from TARGET.result r where r.id=orig.id);
create view TARGET.indi_funder_fairness as select * from SOURCE.indi_funder_fairness;
create view TARGET.indi_funder_openess as select * from SOURCE.indi_funder_openess;
create view TARGET.indi_funder_findable as select * from SOURCE.indi_funder_findable;
create view TARGET.indi_ris_fairness as select * from SOURCE.indi_ris_fairness;
create view TARGET.indi_ris_openess as select * from SOURCE.indi_ris_openess;
create view TARGET.indi_ris_findable as select * from SOURCE.indi_ris_findable;

View File

@ -15,6 +15,7 @@ create view if not exists TARGET.doctoratestudents as select * from SOURCE.docto
create view if not exists TARGET.totalresearchers as select * from SOURCE.totalresearchers;
create view if not exists TARGET.totalresearchersft as select * from SOURCE.totalresearchersft;
create view if not exists TARGET.hrrst as select * from SOURCE.hrrst;
create view if not exists TARGET.graduatedoctorates as select * from SOURCE.graduatedoctorates;
create table TARGET.result stored as parquet as
select distinct * from (
@ -73,7 +74,11 @@ create table TARGET.result stored as parquet as
'openorgs____::c0b262bd6eab819e4c994914f9c010e2', -- National Institute of Geophysics and Volcanology
'openorgs____::1624ff7c01bb641b91f4518539a0c28a', -- Vrije Universiteit Amsterdam
'openorgs____::4d4051b56708688235252f1d8fddb8c1', --Iscte - Instituto Universitário de Lisboa
'openorgs____::ab4ac74c35fa5dada770cf08e5110fab' -- Universidade Católica Portuguesa
'openorgs____::ab4ac74c35fa5dada770cf08e5110fab', -- Universidade Católica Portuguesa
'openorgs____::4d4051b56708688235252f1d8fddb8c1', -- Iscte - Instituto Universitário de Lisboa
'openorgs____::5d55fb216b14691cf68218daf5d78cd9', -- Munster Technological University
'openorgs____::0fccc7640f0cb44d5cd1b06b312a06b9', -- Cardiff University
'openorgs____::8839b55dae0c84d56fd533f52d5d483a' -- Leibniz Institute of Ecological Urban and Regional Development
) )) foo;
--ANALYZE TABLE TARGET.result COMPUTE STATISTICS;
@ -92,6 +97,7 @@ create view if not exists TARGET.doctoratestudents as select * from SOURCE.docto
create view if not exists TARGET.totalresearchers as select * from SOURCE.totalresearchers;
create view if not exists TARGET.totalresearchersft as select * from SOURCE.totalresearchersft;
create view if not exists TARGET.hrrst as select * from SOURCE.hrrst;
--create view if not exists TARGET.graduatedoctorates as select * from SOURCE.graduatedoctorates;
create table TARGET.result_citations stored as parquet as select * from SOURCE.result_citations orig where exists (select 1 from TARGET.result r where r.id=orig.id);
--ANALYZE TABLE TARGET.result_citations COMPUTE STATISTICS;
@ -274,3 +280,13 @@ create table TARGET.indi_pub_interdisciplinarity stored as parquet as select * f
--ANALYZE TABLE TARGET.indi_pub_interdisciplinarity COMPUTE STATISTICS;
create table TARGET.result_apc_affiliations stored as parquet as select * from SOURCE.result_apc_affiliations orig where exists (select 1 from TARGET.result r where r.id=orig.id);
--ANALYZE TABLE TARGET.result_apc_affiliations COMPUTE STATISTICS;
create table TARGET.indi_is_project_result_after stored as parquet as select * from SOURCE.indi_is_project_result_after orig where exists (select 1 from TARGET.result r where r.id=orig.id);
create table TARGET.indi_is_funder_plan_s stored as parquet as select * from SOURCE.indi_is_funder_plan_s orig where exists (select 1 from TARGET.result r where r.id=orig.id);
create view TARGET.indi_funder_fairness as select * from SOURCE.indi_funder_fairness;
create view TARGET.indi_funder_openess as select * from SOURCE.indi_funder_openess;
create view TARGET.indi_funder_findable as select * from SOURCE.indi_funder_findable;
create view TARGET.indi_ris_fairness as select * from SOURCE.indi_ris_fairness;
create view TARGET.indi_ris_openess as select * from SOURCE.indi_ris_openess;
create view TARGET.indi_ris_findable as select * from SOURCE.indi_ris_findable;

View File

@ -54,8 +54,11 @@ create table TARGET.result stored as parquet as
'openorgs____::c0b262bd6eab819e4c994914f9c010e2', -- National Institute of Geophysics and Volcanology
'openorgs____::1624ff7c01bb641b91f4518539a0c28a', -- Vrije Universiteit Amsterdam
'openorgs____::4d4051b56708688235252f1d8fddb8c1', --Iscte - Instituto Universitário de Lisboa
'openorgs____::ab4ac74c35fa5dada770cf08e5110fab' -- Universidade Católica Portuguesa
'openorgs____::ab4ac74c35fa5dada770cf08e5110fab', -- Universidade Católica Portuguesa
'openorgs____::4d4051b56708688235252f1d8fddb8c1', -- Iscte - Instituto Universitário de Lisboa
'openorgs____::5d55fb216b14691cf68218daf5d78cd9', -- Munster Technological University
'openorgs____::0fccc7640f0cb44d5cd1b06b312a06b9', -- Cardiff University
'openorgs____::8839b55dae0c84d56fd533f52d5d483a' -- Leibniz Institute of Ecological Urban and Regional Development
))) foo;
--ANALYZE TABLE TARGET.result COMPUTE STATISTICS;

View File

@ -467,7 +467,7 @@
<argument>${usage_stats_db_shadow_name}</argument>
<file>finalizeImpalaCluster.sh</file>
</shell>
<ok to="End"/>
<ok to="Step24-updateCache"/>
<error to="Kill"/>
</action>