added check not to dump deletedByInference entities

This commit is contained in:
Miriam Baglioni 2021-07-13 16:11:46 +02:00
parent e9a17ec899
commit 5295d10691
3 changed files with 7 additions and 2 deletions

View File

@ -453,6 +453,7 @@ public class DumpGraphEntities implements Serializable {
.map(
(MapFunction<E, Organization>) o -> mapOrganization((eu.dnetlib.dhp.schema.oaf.Organization) o),
Encoders.bean(Organization.class))
.filter(Objects::nonNull)
.write()
.mode(SaveMode.Overwrite)
.option("compression", "gzip")
@ -460,6 +461,8 @@ public class DumpGraphEntities implements Serializable {
}
private static Organization mapOrganization(eu.dnetlib.dhp.schema.oaf.Organization org) {
if(org.getDataInfo().getDeletedbyinference())
return null;
Organization organization = new Organization();
Optional

View File

@ -110,9 +110,11 @@ public class SparkSelectValidRelationsJob implements Serializable {
"UNION ALL " +
"SELECT id " +
"FROM project " +
"WHERE datainfo.deletedbyinference = false AND datainfo.invisible = false " +
"UNION ALL " +
"SELECT id " +
"FROM datasource ")
"FROM datasource " +
"WHERE datainfo.deletedbyinference = false AND datainfo.invisible = false " )
.createOrReplaceTempView("identifiers");
spark

View File

@ -88,7 +88,7 @@ public class DumpOrganizationProjectDatasourceTest {
org.apache.spark.sql.Dataset<eu.dnetlib.dhp.schema.dump.oaf.graph.Organization> verificationDataset = spark
.createDataset(tmp.rdd(), Encoders.bean(eu.dnetlib.dhp.schema.dump.oaf.graph.Organization.class));
Assertions.assertEquals(34, verificationDataset.count());
Assertions.assertEquals(15, verificationDataset.count());
verificationDataset
.foreach(