Behavior change of VALUES with respect to FILTER inside an OPTIONAL group

6 views
Skip to first unread message

Manuel Fiorelli

unread,
Jun 1, 2021, 8:51:18 PMJun 1
to rdf4j...@googlegroups.com
Dear all,

sorry for the second email in a row...

I've hit another change in the behavior of the VALUES clause. In this case, there is a change in how VALUES interacts with FILTER inside an OPTIONAL group.

Please consider the following query:

SELECT ?datasetBound {
  OPTIONAL {
    VALUES(?dataset ?uriSpace) {
       (<http://example.org/void.ttl#FOAF> "http://xmlns.com/foaf/0.1/")  
    }
    FILTER(STRSTARTS(STR(<http://example.com>), ?uriSpace))
  }
  BIND(BOUND(?dataset) as ?datasetBound)
}

This query returns a single solution with datasetBound set to true.
I'm pretty sure that in previous versions the results would have been false.
Actually, I was able to obtain this result by wrapping the VALUES section within a pair of braces

SELECT ?datasetBound {
  OPTIONAL {
    {VALUES(?dataset ?uriSpace) {
       (<http://example.org/void.ttl#FOAF> "http://xmlns.com/foaf/0.1/")  
      }}
    FILTER(STRSTARTS(STR(<http://example.com>), ?uriSpace))
  }
  BIND(BOUND(?dataset) as ?datasetBound)
}

Looking at specs (https://www.w3.org/TR/sparql11-query/#sparqlAlgebraFinalValues), I'm unsure which behavior is right. My idea in favor of the new behavior is that the VALUES section is "evaluated" after the FILTER, thus joining an empty binding set (because FILTER is unsatisfied) with the contents of VALUES.

Regards,
Manuel Fiorelli

Jeen Broekstra

unread,
Jun 2, 2021, 5:53:21 AMJun 2
to RDF4J Users
I think this may be a bug as well, probably caused by the same optimization we introduced in 3.7.0. I've only looked briefly but AFAICT ?dataset should not be bound to any value if the filter fails (because the values clause is _inside_ the optional clause together with the filter, and everything in the optional clause should either completely succeed or completely fail). 

Jeen
--
You received this message because you are subscribed to the Google Groups "RDF4J Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rdf4j-users...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages