Repository navigation
Description
The other half of the ParserOptions default, and the open decision D-11 from the burn-down roadmap ("lexical-form preservation vs documented value-matching divergence" — docs/audit/burn-down/ROADMAP.md §4). Filing it as a tracking issue the way #1442 tracked D-2, because it currently blocks group01 and roughly eight expression-cluster register entries, and because two of the burn-down cluster docs assumed different outcomes for it. Verified at 47e96b7b6.
Repro
@prefix ex: <http://example.org/> .
ex:x1 ex:v 01 .
ex:x2 ex:v +1 .
ex:x3 ex:v 1 .$ fluree query lex --sparql 'SELECT ?s (STR(?o) AS ?lex) (DATATYPE(?o) AS ?dt) WHERE { ?s ?p ?o }'
ex:x1 1 xsd:integer
ex:x2 1 xsd:integer
ex:x3 1 xsd:integer
In RDF those are three distinct terms with the same value. After ingest they are one term, and nothing downstream can tell them apart.
Mechanism
NumericStyle::Canonicalize is the ParserOptions default (fluree-graph-turtle/src/options.rs:52): Integer and Double tokens are parsed into native LiteralValues and the source spelling is discarded. Ingest takes the default via fluree_graph_turtle::parse (parser.rs:1494), called from fluree-db-transact/src/import.rs:183, :535, :910.
Two lexical forms already survive today, which is worth knowing before designing the fix: Decimal tokens keep their spelling, and integers past i64 keep theirs so downstream can promote to BigInt (parser.rs:961, :1651). So the storage layer is not uniformly value-only — the gap is specifically i64-range integers and doubles.
NumericStyle::PreserveLexical (options.rs:58) already implements the other side and is exercised by the W3C RDF-syntax suites; as with collections, it just isn't reachable from an ingest surface.
Why it matters
Term identity, not value comparison, is what breaks. SPARQL GROUP BY ?x, DISTINCT, sameTerm, and COUNT(DISTINCT ?x) are defined on terms, so a dataset that distinguishes 01 from 1 gets silently merged into one group. That's the group01 failure, and the roadmap's note that it is "unimplementable as scoped because integer lexical forms are canonicalized at ingest" is the same observation from the other end.
For most users storing numbers this is invisible and arguably desirable. It bites the user who is round-tripping someone else's RDF and expects to get back what they put in.
The decision (D-11)
- Preserve the lexeme — a lexical column alongside the value, so terms keep their identity and the value paths are unchanged. This is an ingest and storage format change, so it wants a real design pass and probably a migration note; it is the option that greens
group01and the expression entries. - Documented divergence — state that Fluree stores numeric literals by value, not by lexical form, and that
01and1are the same term here. Zero cost, permanent register entries, and it needs to be said out loud in the docs rather than left implicit.
I don't think this one should be decided inside an implementation PR — it changes what a Fluree literal is. Whichever way it goes, docs/contributing/sparql-compliance.md should carry the answer so the next person doesn't re-derive it.
Related: the same ParserOptions default also flattens RDF collections and drops () statements (D-13) — filed separately. Note that STR() on a double is separately wrong even under the divergence option, since the canonical form is well-defined — also filed separately.
Activity