You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Gottfried Schenner (JIRA)" <ji...@apache.org> on 2014/05/28 10:39:02 UTC

[jira] [Created] (JENA-704) SPARQL Query: FILTER requires BIND to work as expected

Gottfried Schenner created JENA-704:
---------------------------------------

             Summary: SPARQL Query: FILTER requires BIND to work as expected
                 Key: JENA-704
                 URL: https://issues.apache.org/jira/browse/JENA-704
             Project: Apache Jena
          Issue Type: Bug
          Components: ARQ, Jena
    Affects Versions: Jena 2.11.1
         Environment: Win7
Jena:       VERSION: 2.11.1
Jena:       BUILD_DATE: 2014-01-18T19:01:20+0000
ARQ:        VERSION: 2.11.1
ARQ:        BUILD_DATE: 2014-01-18T19:01:20+0000

            Reporter: Gottfried Schenner
            Priority: Minor


Example of a SPARQL-Query that works only as expected, when the condition is bound in a variable i.e. the following example works only if   BIND(STR(?y) <= STR(?x) AS ?cond) and FILTER(?cond)  is used, instead of FILTER(STR(?y)<=STR(?x))
In Jena 2.11.0 it works without the BIND statement.

Example:
Data:
----
@prefix : <http://www.example.org/test#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

:A a owl:Class .
:B a owl:Class .
:A1 a :A .
:B1 a :B .
:B2 a :B .

----
Query:

PREFIX owl: <http://www.w3.org/2002/07/owl#> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 

SELECT ?x (COUNT(?y) AS ?index)
WHERE {
  {  ?x rdf:type/rdfs:subClassOf* :A .}
  UNION
  {  ?x rdf:type/rdfs:subClassOf* :B .}
  
  {  ?y rdf:type/rdfs:subClassOf* :A .}
  UNION
  {  ?y rdf:type/rdfs:subClassOf* :B .}  
  FILTER(STR(?y)<=STR(?x))
  #BIND(STR(?y) <= STR(?x) AS ?cond)
  #FILTER(?cond)  
} GROUP BY (?x)

----
Expected result:
---------------
| x   | index |
=========
| :B2 | 3     |
| :B1 | 2     |
| :A1 | 1     |
--------------
----
Actual result:
-------------
| x | index |
=============
|   | 0     |
-------------



--
This message was sent by Atlassian JIRA
(v6.2#6252)