comunica / sparqlee

⚙️ SPARQL expression evaluator library - Moved to @comunica/expression-evaluator
https://www.npmjs.com/package/sparqlee
14 stars 7 forks source link

Aggregators Min and Max call Ordering file #180

Closed jitsedesmet closed 1 year ago

jitsedesmet commented 1 year ago

This PR aims to resolve https://github.com/comunica/comunica/issues/1212. According to the spec, Min and Max should make use of the SPARQL ORDER BY ordering definition. I assume sparqlee implements this in Ordering.ts (Both the spec and the implementation are wild to me, so please correct me if this assumption is wrong).

~The issue also makes me wonder whether there are problems regarding date (and similar types) within the other aggregators, since all aggregators call the typedValue of a literal. Before https://github.com/comunica/sparqlee/pull/163 this was always some basic JS type (if I recall correctly), but now there are also object typedValues, these do not implement the + operator for example.~ The other aggregators do call the regularFunctions so should work.

coveralls commented 1 year ago

Coverage Status

coverage: 100.0%. remained the same when pulling de4cc48150cbfed7c4e98b8412bef3ee1a7983e5 on jitsedesmet:fix/min-of-date into 6c22f3774dcac333c131710f0a6843d9f25c1d8c on comunica:master.

jitsedesmet commented 1 year ago

This seems to resolve the problem. Query:

SELECT (MIN(?of) as ?min) (MAX(?of) as ?max)
where {
    ?p ?o ?of.
}

over:

<http://example.com/apple> <http://www.w3.org/2001/XMLSchema#datePred> "2010-06-21+08:00"^^<http://www.w3.org/2001/XMLSchema#date>.
<http://example.com/pear> <http://www.w3.org/2001/XMLSchema#datePred> "2010-06-21-08:00"^^<http://www.w3.org/2001/XMLSchema#date>.

gives:

[
{"max":"\"2010-06-21-08:00\"^^http://www.w3.org/2001/XMLSchema#date","min":"\"2010-06-21+08:00\"^^http://www.w3.org/2001/XMLSchema#date"}
]