Merge mappings with equal SQL table and subject map
convert mappings which just project different columns from one table into one TripleMap, assuming this is safe (which I guess amounts to checking if the subjectMaps are equal).
So the two mappings (map:m-1, map:m-2) below (they only differ on y1/y2), should be trandformed into map:supermap, also below, which uses tt:table instead of R2RMLView, and contains multiple predicateObjectMap-s. The benefit is at least less duplication of the subjectMap.
map:m-1
a rr:TriplesMap ;
rr:logicalTable [
a rr:R2RMLView ;
rr:sqlQuery """
SELECT
x, y1 from tableA"""
] ;
rr:predicateObjectMap [
a rr:PredicateObjectMap ;
rr:objectMap [
a rr:ObjectMap, rr:TermMap ;
rr:column "y1" ;
rr:termType rr:Literal
] ;
rr:predicate npdv:myY1
] ;
rr:subjectMap [
a rr:SubjectMap, rr:TermMap ;
rr:template "http://sws.ifi.uio.no/data/{x}" ;
rr:termType rr:IRI
] .
map:m-2
a rr:TriplesMap ;
rr:logicalTable [
a rr:R2RMLView ;
rr:sqlQuery """
SELECT
x, y2 from tableA"""
] ;
rr:predicateObjectMap [
a rr:PredicateObjectMap ;
rr:objectMap [
a rr:ObjectMap, rr:TermMap ;
rr:column "y2" ;
rr:termType rr:Literal
] ;
rr:predicate npdv:myY2
] ;
rr:subjectMap [
a rr:SubjectMap, rr:TermMap ;
rr:template "http://sws.ifi.uio.no/data/{x}" ;
rr:termType rr:IRI
] .
map:supermap
a rr:TriplesMap ;
rr:logicalTable [ rr:tableName "tableA" ]
rr:predicateObjectMap [
a rr:PredicateObjectMap ;
rr:objectMap [
a rr:ObjectMap, rr:TermMap ;
rr:column "y1" ;
rr:termType rr:Literal
] ;
rr:predicate npdv:myY1
] ;
rr:predicateObjectMap [
a rr:PredicateObjectMap ;
rr:objectMap [
a rr:ObjectMap, rr:TermMap ;
rr:column "y2" ;
rr:termType rr:Literal
] ;
rr:predicate npdv:myY2
] ;
rr:subjectMap [
a rr:SubjectMap, rr:TermMap ;
rr:template "http://sws.ifi.uio.no/data/{x}" ;
rr:termType rr:IRI
] .