dnet-hadoop/dhp-workflows/dhp-usage-stats-update/src/main/resources/eu/dnetlib/dhp/oa/graph/usagestatsupdate/oozie_app/scripts/Step15.sql

19 lines
722 B
SQL

--SARC Downloads
CREATE TABLE IF NOT EXISTS ${usageStatsDB}.sarc_downloads_stats_tmp
(`source` string,
`repository_id` string,
`result_id` string,
`date` string,
`count` bigint,
`openaire` bigint);
INSERT INTO ${usageStatsDB}.sarc_downloads_stats_tmp
SELECT s.source, d.id AS repository_id,
ro.id as result_id, CONCAT(CAST(YEAR(`date`) AS STRING), '/',
LPAD(CAST(MONTH(`date`) AS STRING), 2, '0')) AS `date`, s.count, '0'
FROM ${usageRawDataDB}.sushilog s, ${statsDB}.datasource_oids d, ${statsDB}.result_pids ro
WHERE d.oid LIKE CONCAT('%', s.repository, '%') AND d.id like CONCAT('%', 'sarcservicod', '%')
AND s.rid=ro.pid AND ro.type='Digital Object Identifier' AND s.metric_type='ft_total' AND s.source='SARC-OJS';