You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VALUES bare integer lowered as xsd:long, big integer as xsd:integer — inconsistent, risks silent join misses #1343
A bare integer in a SPARQL VALUES clause is lowered with datatype xsd:long, while a large-magnitude bare integer (one that overflows i64) is lowered as xsd:integer. This is inconsistent, non-conformant with the SPARQL spec, and can cause silent join misses against stored xsd:integer data.
Details
In fluree-db-sparql/src/lower/term.rs (lower_value_literal):
Per SPARQL 1.1, an unsuffixed integer literal has datatype xsd:integer. The typed-literal and triple-pattern lowering paths already use xsd:integer; the VALUES bare-integer arm tagging xsd:long is the outlier.
Impact
Hash joins normalize literals through binding_to_group_key_normalized → encoded_equivalent, where an xsd:long-tagged integer encodes to (NUM_INT, encode_i64(v), dt_id = LONG) and an xsd:integer-tagged integer encodes to (..., dt_id = INTEGER). GroupKeyOwned::Lit includes dt_id, so although o_kind/o_key are identical, the differing dt_id places the two values in different hash buckets.
Result: on the normalized-key hash-join path, VALUES ?o { 42 } (tagged xsd:long) does not match stored xsd:integer data, whereas VALUES ?o { 99999999999999999999 } (tagged xsd:integer) does. Same-shaped query, opposite results depending on the magnitude of the constant.
Note: the inline VALUES operator path (values.rs) matches value-based via FlakeValue::eq (datatype-agnostic), so this only manifests when VALUES is executed as a hash join.
Suggested fix
Change the LiteralValue::Integer arm in lower_value_literal to tag xsd_names::INTEGER, matching the spec and the BigInteger/pattern paths.
Add a regression test that joins a bare VALUES ?x { 42 } against stored xsd:integer data and asserts a match.
Related
Surfaced during review of #1332 (decimal/integer exactness). The current test suite covers typed VALUES ("…"^^xsd:integer) but not the bare-integer case.
Closing as a duplicate of #1319, which tracks the same root cause — a bare integer literal lowering to xsd:long while stored integers materialize as xsd:integer, so the same number becomes two distinct RDF terms — and the same fix locus, the VALUES Integer arm in fluree-db-sparql/src/lower/term.rs. #1319 is the broader umbrella (VALUES + expressions, plus the integer-family canonicalization option), so let's consolidate there. I'll comment there to also see this issue for more information.
Activity
aaj3f commentedon Jun 29, 2026
Closing as a duplicate of #1319, which tracks the same root cause — a bare integer literal lowering to
xsd:longwhile stored integers materialize asxsd:integer, so the same number becomes two distinct RDF terms — and the same fix locus, the VALUESIntegerarm influree-db-sparql/src/lower/term.rs. #1319 is the broader umbrella (VALUES + expressions, plus the integer-family canonicalization option), so let's consolidate there. I'll comment there to also see this issue for more information.