Re: Semantic of FILTER NOT IN / literal comparison

On 16/04/16 07:23, Michael Schmidt wrote:
> Dear community,
>
> we’ve got a question regarding the semantics of FILTER NOT IN (inspired
> by
> http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-not-in-02),
> which boils down to literal equality issues.

I don't see that test in that manifest.

Also,
> syntax-sparql1

Those are syntax tests, not evaluation tests.

In that manifest, all tests are "#syntax-...."

>
> Look at the following example:
>
> - Data: <http://s> <http://p> "a” .
> - Query:
>
> SELECT * WHERE {
>    ?s ?p ?o
>    FILTER (?o NOT IN (1))
> }
>
> According to the standard ("The |NOT IN| operator is equivalent to the
> SPARQL expression: (lhs != expression1) && (lhs != expression2) && …)”)
> this query is equivalent to:
>
> SELECT * WHERE {
>    ?s ?p ?o
>    FILTER (?o!=1)
> }
>
> Further, the standard says "The test is done with "!=" operator, which
> tests for not the same value, as determined by the operator mapping
> <https://www.w3.org/TR/sparql11-query/#OperatorMapping>.”, where the
> operator mapping section defines no explicit rule for comparing plain
> literals to numerics (but delegates to various casting/substitution
> rules defined in XPath standards) .
>
> My questions now are:
> - What is the expected result of “a”!=1? And why — which of the rules in
> the operator mapping table would apply here (if any?). The expected
> result of sparql11-not-in-02 indicates that this neq comparison should
> evaluate to true rather than error, but I actually do not see why.

There is no implicit casting in SPARQL.

If there is no mapping then it is a evaluation error.

(specific engines may do better - for example the value space of strings 
and the value space of integers don't overlap so the answer is "false")

> - Would the result be different in the context of RDF1.1, where wecwould
> compare “a”^^xsd:string!=1 instead?

No.

>
> Thanks in advance for any help,
> Michael
>

 Andy

PS You may be interested in the community work to maintain the RDF 1.1 
and SPARQL 1.1 tests:

https://www.w3.org/community/rdf-tests/
https://github.com/w3c/rdf-tests

Received on Saturday, 16 April 2016 09:56:14 UTC