You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Rob Vesse (JIRA)" <ji...@apache.org> on 2014/05/28 11:33:01 UTC
[jira] [Updated] (JENA-704) SPARQL Query: FILTER requires BIND to
work as expected
[ https://issues.apache.org/jira/browse/JENA-704?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Rob Vesse updated JENA-704:
---------------------------
Description:
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:
{noformat}
@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 .
{noformat}
Query:
{noformat}
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)
{noformat}
Expected result:
{noformat}
---------------
| x | index |
=========
| :B2 | 3 |
| :B1 | 2 |
| :A1 | 1 |
--------------
{noformat}
Actual result:
{noformat}
-------------
| x | index |
=============
| | 0 |
-------------
{noformat}
was:
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:
{noformat}
@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 .
{noformat}
Query:
{noformat}
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#>
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)
{noformat}
Expected result:
{noformat}
---------------
| x | index |
=========
| :B2 | 3 |
| :B1 | 2 |
| :A1 | 1 |
--------------
{noformat}
Actual result:
{noformat}
-------------
| x | index |
=============
| | 0 |
-------------
{noformat}
> 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:
> {noformat}
> @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 .
> {noformat}
> Query:
> {noformat}
> 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)
> {noformat}
> Expected result:
> {noformat}
> ---------------
> | x | index |
> =========
> | :B2 | 3 |
> | :B1 | 2 |
> | :A1 | 1 |
> --------------
> {noformat}
> Actual result:
> {noformat}
> -------------
> | x | index |
> =============
> | | 0 |
> -------------
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.2#6252)