semsol / arc2

ARC RDF Classes for PHP
Other
332 stars 89 forks source link

ARC2_Store::query: function SUM fails sometimes, because it is rounding #100

Open k00ni opened 6 years ago

k00ni commented 6 years ago

I don't expect this issue to be solved soon, but i want to document it because i need it for a pull request.

Given the following RDF:

@prefix : <http://www.example.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

:ints :int 1, 2, 3 .
:decimals :dec 1.0, 2.2, 3.5 .
:doubles :double 1.0E2, 2.0E3, 3.0E4 .
:mixed1 :int 1 ; :dec 2.2 .
:mixed2 :double 2E-1 ; :dec 2.2 .

The following query:

PREFIX : <http://www.example.org/>
SELECT (SUM(?o) AS ?sum)
WHERE {
    ?s :dec ?o
}

should return:

array {
  'variables' => array { "sum" }
  'rows' => array {
    array {
      'sum' => "11.1"
      'sum type' => 'literal"
    }
  }
}

but returns

array {
  'variables' => array { "sum" }
  'rows' => array {
    array {
      'sum' => "11" // <=============== problem
      'sum type' => 'literal"
    }
  }
}