Skip to content

r2rml: constant literal objects (rr:object / rr:constant) lose their datatype #1798

Open

Description

@bplatz

Discovered during the review of #1581 (graph-map refusals); kept out of that PR because it is object maps, not graph maps.

A constant literal object loses its datatype at mapping load. constant_from_term in fluree-db-r2rml/src/loader/extractor.rs builds ConstantValue::Literal { datatype: None, .. } for every literal (there is a standing // TODO: extract datatype), so both spellings below mint a plain string:

rr:predicateObjectMap [ rr:predicate ex:count ; rr:object "5"^^xsd:integer ] .
rr:predicateObjectMap [ rr:predicate ex:count ; rr:objectMap [ rr:constant "5"^^xsd:integer ] ] .

extract_object_map does read a sibling rr:datatype, but returns through constant_from_term on the rr:constant path without passing it, so rr:objectMap [ rr:constant "5" ; rr:datatype xsd:integer ] is dropped the same way. The language tag is kept, so "x"@en survives while "5"^^xsd:integer does not.

Downstream, materialize_object_from_batch (materialize/term.rs) calls object_map_dtc(None, None) and emits an untyped literal, and ledger_info.rs reports every constant literal as xsd:string. So the value is stored and compared as a string on every surface: the virtual query path, the tracking materializer, and the twin builder. A typed constant only ever works when the mapping is built programmatically with the datatype set.

Fix sketch

  • constant_from_term carries the literal's own datatype from Term::Literal { datatype, .. } (plain strings stay None so nothing that works today changes).
  • On the rr:constant object path, apply the R2RML rule for a sibling rr:datatype (the spec restricts datatype overrides to column- and template-valued term maps; decide whether to refuse or apply it, and say so in the error or docs).
  • Twin tests on both surfaces per repo convention: an extractor test for each spelling, plus a query-path and a materialize assertion that the object comes back typed.

Activity

  1. added
    bug
    P2
    area:iceberg
    on Sep 6, 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

    P2area:icebergbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions