W3C home > Mailing lists > Public > public-sparql-dev@w3.org > April to June 2016

Semantic of FILTER NOT IN / literal comparison

From: Michael Schmidt <ms@metaphacts.com>
Date: Sat, 16 Apr 2016 08:23:00 +0200
Message-Id: <C2A20490-41D4-4F28-AC4D-EFC5CAFD4759@metaphacts.com>
To: public-sparql-dev@w3.org
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 <http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql1/manifest#sparql11-not-in-02>), which boils down to literal equality issues.

Look at the following example:

- Data: <http://s <http://s/>> <http://p <http://p/>> "a” .
- Query:

  ?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:

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

Thanks in advance for any help,

Received on Saturday, 16 April 2016 06:23:30 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:27:06 UTC