Skip to content

R2RML: a template-valued object map with no rr:termType produces a literal (the §7.4 default is IRI) #2039

Open

Description

@aaj3f

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 is Iri
    (sql_lane/lower.rs L1559),
    and ledger info reports the predicate as xsd:string
    (ledger_info.rs L1294).
  • An unrecognized rr:termType value, such as a typo, also silently becomes Literal.
  • Subject maps: rr:termType rr:Literal is accepted at load
    (extractor.rs L231–237)
    and only fails row by row. §7.4 allows only rr:IRI or rr:BlankNode for a subject map.

Proposal

  • Apply the §7.4 default: a template-valued object map without rr:language or rr:datatype is an
    IRI.
  • Reject, at load, an unrecognized rr:termType and 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 set rr:termType rr:IRI explicitly, 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

  1. added
    bug
    area:iceberg
    on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:icebergbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions