Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Problem with negating IN expression in FILTER #147

Open
joerixaop opened this Issue · 3 comments

3 participants

@joerixaop

problem exist in 6.1.6 and 7.1, with slightly different symptoms

Test data:

PREFIX vocab: <http://example.com/vocab#>

WITH <http://test.graph/>
INSERT {
  <http://example.com/Book/1> a vocab:Book;
                              vocab:title "Book 1" .
}

On 7.1/6.1.8

Following query should should return 0 rows, returns 1:

PREFIX vocab: <http://example.com/vocab#>

SELECT DISTINCT ?me ?var3 DATATYPE(?var3) AS ?var4
WHERE {
  GRAPH <http://test.graph/> {
    ?me vocab:title ?var3
    FILTER (!(DATATYPE(?var3) IN (<http://www.w3.org/2001/XMLSchema#string>,<http://www.w3.org/2001/XMLSchema#float>)))
  }
}

Following query should return 0 rows, does return 0 rows):

PREFIX vocab: <http://example.com/vocab#>

SELECT DISTINCT ?me ?var3 DATATYPE(?var3) AS ?var4
WHERE {
  GRAPH <http://test.graph/> {
    ?me vocab:title ?var3
    FILTER (!(DATATYPE(?var3) IN (<http://www.w3.org/2001/XMLSchema#string>)))
  }
}

On 6.1.6

This should return no results, but returns 1 result:

PREFIX vocab: <http://example.com/vocab#>

SELECT DISTINCT ?me ?var3
WHERE {
  GRAPH <http://test.graph/> {
    ?me vocab:title ?var3
    FILTER (!(?var3 IN ("Book 1", "Book 2")))
  }
}

whereas this correctly returns 0 rows

PREFIX vocab: <http://example.com/vocab#>

SELECT DISTINCT ?me ?var3
WHERE {
  GRAPH <http://test.graph/> {
    ?me vocab:title ?var3
    FILTER (!(?var3 IN ("Book 1")))
  }
}

Manually converting the ?a NOT IN (?b, ?c,..) to (?a != ?b AND ?a != ?b AND ?a != ...) works in any version, but obviously I shouldn't need to do that.

@iv-an-ru iv-an-ru was assigned by openlink
@HughWilliams
Collaborator

This problem has been recreated and reported to development to fix ...

@joerixaop

The 6.1.6 behavior with strings now also happens on the dev/6 branch, I'm fairly certain that it didn't happen in 6.1.8

It seems to be an issue with a cast failing. If I take the generated SQL query from sparql_to_sql_text and remove the OPTIONS (QUIETCAST) it suddenly fails on 6.1.6 and later with the error SR066 "Unsupported case case in CONVERT (VARCHAR -> Rdf)"

This despite the fact that DB.DBA.RDF_OBJ_OF_SQLVAL('Book 1') works without problems if I SELECT it or use it in a simple equality check.

This does explain the observed behavior though, a quiet cast will turn this into NULL and variable NOT IN (NULL, ...) is always true.

Now if I only understood what happend to RDF_OBJ_OF_SQLVAL

@joerixaop

And it seems on the dev/7 branch that the quiet cast is turned of, because now I get "SR066: Unsupported case in CONVERT (VARCHAR -> UNAME)" for that first query (FILTER (!(DATATYPE(?var3) IN (<http://www.w3.org/2001/XMLSchema#string>,<http://www.w3.org/2001/XMLSchema#float>))))

edit: it's not turned of, so something in the behavior of quietcast has changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.