Skip to content

R2RML: an un-annotated rr:column should get its natural datatype (R2RML §10.2), with one effective datatype every lane respects #2192

Open

Description

@aaj3f

R2RML §10.2 says an rr:column with no rr:datatype gets the natural RDF literal of the column's SQL type (integers → xsd:integer, decimals → xsd:decimal, doubles → xsd:double, booleans, dates, timestamps, binary → xsd:hexBinary). We read every such column as xsd:string of its rendering instead. docs/graph-sources/sql.md says so; docs/graph-sources/iceberg.md's type table claims otherwise. The practical effect is that a hand-written mapping over numeric columns silently gets string semantics: FILTER(?v > 80) returns nothing, ORDER BY and MIN/MAX are lexical, SUM is unbound, and values don't join with native typed data.

The design we've settled on:

  • One effective datatype per object map. rr:datatype when present, else the column's natural type, through the generator's existing xsd_datatype (fluree-db-r2rml/src/emit/naming.rs), which is already R2RML's natural table. The one deliberate deviation is Float32 → xsd:float, which is exact for an f32. It's extended for Iceberg time → xsd:time and uuid → xsd:string. Every site that decides a column term's typing reads it: the materializer, the literal encoder, the materialize sinks, ledger-info, pushdown coercion, the fused-aggregate and SQL-lane gates, and preview. So a hand-written and a generated mapping behave identically, and no lane can disagree with another (the bug class behind R2RML: lanes group, order and compare an un-annotated column by its physical value instead of its term (empty GROUP BY, wrong MIN/MAX, ORDER BY … LIMIT and FILTER results) #2191).
  • Lane coverage includes ANNOTATED columns whose declared type disagrees with the physical type: an xsd:integer-annotated text column read by the fused integer key, a numeric class over a varchar in the SQL lane, an rr:termType rr:IRI map over a non-text column. These are the cases R2RML: lanes group, order and compare an un-annotated column by its physical value instead of its term (empty GROUP BY, wrong MIN/MAX, ORDER BY … LIMIT and FILTER results) #2191 leaves open.
  • Constant matching becomes native-consistent: value equality within a type family (1 matches 1.0), never across families ("1" doesn't match 1), which is what native ledgers already do. Today the R2RML operator's residual match is lexical and crosses families, so a virtual source and its materialized target answer the same query differently.
  • Lexical forms: only the invalid ones are fixed (a naive timestamp gets no Z; time renders as HH:MM:SS[.ffffff], not micros; uuids are dashed). Template and join-key rendering stays byte-identical, so no subject IRI changes.
  • Materialized targets: a change in a source's effective typing forces one full refresh (a typing version folded into the mapping hash that's recorded today but never compared), so a target never holds mixed string and typed facts.
  • No compatibility flag. rr:datatype xsd:string on a column is R2RML's own per-column opt-out, and the release note will say so.
  • Docs: fix the iceberg.md and sql.md type tables and the un-annotated numeric examples in r2rml.md / sql.md.

This changes query results for hand-written mappings, so it'll ship as breaking-change.

Activity

  1. added
    enhancement
    P2
    area:query
    on Oct 27, 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:queryenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions