Skip to content

Special double values on the remaining surfaces: rendering, division, casts, JSON-LD filter atoms, coercion, MEDIAN/VARIANCE/STDDEV #2073

Open

Description

@aaj3f

#2044 makes every xsd:double indexable and gives the special values (INF, -INF, NaN) SPARQL's semantics on every read lane, the fix for #2043. bplatz's review of #2044 found a handful of surfaces outside its diff that still treat them their own way, all pre-existing, and #2044 listed the aggregate one itself.

  • Two writers render INF and NaN as null: commit detail flakes (fluree-db-api/src/graph_commit_builder.rs) and SHACL validation results' sh:value (fluree-db-api/src/validate.rs), since a non-finite f64 serializes to JSON null.
  • Double division by zero is an error. op:numeric-divide gives INF, -INF or NaN for doubles, and op:numeric-mod gives NaN.
  • xsd:boolean(NaN) is unbound; XPath casting gives false.
  • JSON-LD filter atoms parse numbers their own way. JSON-LD filter s-expression atoms parse numbers with parse::<f64>() (fluree-db-query/src/parse/filter_sexpr.rs), so (> ?v inf) and (= ?v nan) read Rust's spellings as doubles, where fix(index): every xsd:double value is indexable #2044 puts every other surface on the XSD lexical parser.
  • coerce.rs admits 2^63 as an i64: *d <= i64::MAX as f64 (fluree-db-core/src/coerce.rs) lets 2^63 through and saturates it to i64::MAX, the same off-by-one fix(index): every xsd:double value is indexable #2044 fixes in Hash. The same comparison appears again further down that file, and I'd guess it has the same problem.
  • MEDIAN, VARIANCE and STDDEV leave NaN out, while SUM and AVG propagate it. Making them consistent also needs MEDIAN's sort on the total order fix(index): every xsd:double value is indexable #2044 defines.
  • A stale comment in binary_scan.rs says NaN falls back to discriminant order in Ord.

From #2044 (Follow-ups: MEDIAN, VARIANCE and STDDEV) and bplatz's review of #2044 (the pre-existing items).

Activity

  1. added
    bug
    P3
    area:query
    on Oct 12, 2026
  2. aaj3f commented on Oct 12, 2026

    @aaj3f
    ContributorAuthor

    A few more spots that spell a special double the Rust way (inf, -inf, NaN) rather than in XSD form. These turned up while finishing #2044. Most of them go through FlakeValue's Display (value.rs:1071), so one fix there may well cover several:

    • the SHACL report's lexical form for doubles that aren't xsd:double;
    • sh:pattern input (pattern.rs:16);
    • SHACL-SPARQL message substitution, and report_text;
    • UniqueConstraintViolation.value;
    • the CLI table output (output.rs:316);
    • Cypher typed properties (cypher_typed.rs:1145).

    Separately, JSON-LD results carry INF / NaN as bare strings with no @type, so a client can't tell them apart from the string "INF".

    And fwiw, the stale NaN comment in binary_scan.rs from this checklist is fixed in #2044 (835ae88c4).

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

    P3area:querybug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions