Description
What happens
rr:predicateObjectMap [ rr:predicate ex:customer ;
rr:objectMap [ rr:template "http://example.org/customer/{customer_id}" ] ] .The generated object is the literal "http://example.org/customer/2", not an IRI. A join through
it, such as ?o ex:customer ?c . ?c a ex:Customer against a second triples map whose subjects are
http://example.org/customer/{customer_id}, silently returns 0 rows. Adding rr:termType rr:IRI
gives the expected 200.
Cause
extract_object_map gives every object map the term type Literal when rr:termType is absent
(extractor.rs L511–515),
and the template branch passes that through
(L535–545).
The code disagrees with itself: the programmatic constructor ObjectMap::template() defaults to
Iri (term_map.rs L228–236),
and test_object_map_template pins that. Only mappings loaded from Turtle get the literal.
Spec
R2RML §7.4: when a term map has no rr:termType, its term type is rr:Literal only if it is an
object map and it is column-based, or has rr:language, or has rr:datatype. Otherwise it is
rr:IRI. So a template-valued object map with none of those defaults to IRI.
Also affected
- Template-derived
rdf:type, e.g.
rr:predicate rdf:type ; rr:objectMap [ rr:template "http://example.org/class/{kind}" ], produces
literal "types". The SQL lane's class lowering gives up unless the term type isIri
(sql_lane/lower.rsL1559),
and ledger info reports the predicate asxsd:string
(ledger_info.rsL1294). - An unrecognized
rr:termTypevalue, such as a typo, also silently becomesLiteral. - Subject maps:
rr:termType rr:Literalis accepted at load
(extractor.rsL231–237)
and only fails row by row. §7.4 allows onlyrr:IRIorrr:BlankNodefor a subject map.
Proposal
- Apply the §7.4 default: a template-valued object map without
rr:languageorrr:datatypeis an
IRI. - Reject, at load, an unrecognized
rr:termTypeand a term type that isn't allowed for the map's
position. - It's a behavior change for mappings that rely on the literal default, so call it out in the release
notes. No test in the repo pins the literal default. The two fixtures that use template object maps
already setrr:termType rr:IRIexplicitly, so they stay green.
Related: #1799 and #1798 change the same extract_object_map path (several value sources;
constant literals losing their datatype), so this may be easiest to fix alongside them. #1780's repro
sets rr:termType rr:IRI by hand, which is the workaround for this issue. #1581 already enforces
rr:IRI for graph maps.
Seen on v4.2.3. The code is unchanged on main (745736a) and next (0163f78).
Found with
A local Iceberg harness: moto S3 + Glue mock, pyiceberg-written tables, a two-table R2RML join. It can
be attached as a repro if useful.
See also #2038, the other R2RML loader defect found with the same harness.
Activity