Osma Suominen created JENA-1193:
-----------------------------------
Summary: sdbquery: FILTER within FILTER NOT EXIST has no effect
Key: JENA-1193
URL: https://issues.apache.org/jira/browse/JENA-1193
Project: Apache Jena
Issue Type: Bug
Components: SDB
Affects Versions: Jena 3.1.0
Reporter: Osma Suominen
I noticed that when run within sdbquery, a SPARQL query containing a nested
FILTER NOT EXISTS { ... FILTER (...) } doesn't work the same way as when run on
an in-memory model with the same data.
Here's my data as TriG:
{noformat}
@prefix skos: <http://www.w3.org/2004/02/skos/core#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix ex: <http://example.org/>.
# source graph
ex:src {
ex:src1 rdfs:label "label1" .
ex:src2 rdfs:label "label2" .
}
# destination graph
ex:dst {
ex:dst1 skos:prefLabel "label1" .
ex:dst2 skos:altLabel "label2" .
}
{noformat}
Here's my query:
{noformat}
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX ex: <http://example.org/>
SELECT * {
GRAPH ex:src {
?c1 rdfs:label ?label .
}
FILTER NOT EXISTS {
GRAPH ex:dst {
?c2 ?anyprop ?label .
FILTER (?anyprop != skos:prefLabel)
}
}
}
{noformat}
Results when run with Jena "sparql" command line tool on an in-memory model:
{noformat}
----------------------
| c1 | label |
======================
| ex:src1 | "label1" |
----------------------
{noformat}
Results when run with sdbquery --debug option:
{noformat}
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ex: <http://example.org/>
SELECT *
WHERE
{ GRAPH ex:src
{ ?c1 rdfs:label ?label }
FILTER NOT EXISTS { GRAPH ex:dst
{ ?c2 ?anyprop ?label
FILTER ( ?anyprop != skos:prefLabel )
}
}
}
- - - - - - - - - - - - - -
(prefix ((rdfs: <http://www.w3.org/2000/01/rdf-schema#>))
(filter (notexists
(filter (!= ?anyprop
<http://www.w3.org/2004/02/skos/core#prefLabel>)
(SQL '''SqlSelectBlock/Q_1
Q_1.g = -273327510643043486
Table Q_1 -- ex:dst ?c2 ?anyprop ?label''')
))
(SQL '''SqlSelectBlock/S_1 -- V_1=?c1 V_2=?label
R_1.lex/V_1_lex R_1.datatype/V_1_datatype R_1.lang/V_1_lang
R_1.type/V_1_type
R_2.lex/V_2_lex R_2.datatype/V_2_datatype R_2.lang/V_2_lang
R_2.type/V_2_type
Join/left outer
Join/left outer
SqlSelectBlock/Q_2 -- ?c1:(Q_2.s=>Q_2.X_1)
?label:(Q_2.o=>Q_2.X_2)
Q_2.s/X_1 Q_2.o/X_2
Q_2.g = -317857793313676831
Q_2.p = 6454844767405606854
Table Q_2 -- ex:src ?c1 rdfs:label ?label
Table R_1 -- Var: ?c1
Condition Q_2.X_1 = R_1.hash
Table R_2 -- Var: ?label
Condition Q_2.X_2 = R_2.hash''')
))
SELECT -- V_1=?c1 V_2=?label
R_1.lex AS V_1_lex, R_1.datatype AS V_1_datatype, R_1.lang AS V_1_lang,
R_1.type AS V_1_type,
R_2.lex AS V_2_lex, R_2.datatype AS V_2_datatype, R_2.lang AS V_2_lang,
R_2.type AS V_2_type
FROM
( SELECT -- ?c1:(Q_2.s=>Q_2.X_1)
?label:(Q_2.o=>Q_2.X_2)
Q_2.s AS X_1, Q_2.o AS X_2
FROM Quads AS Q_2 -- ex:src ?c1 rdfs:label ?label
WHERE ( Q_2.g = -317857793313676831 -- Const: ex:src
AND Q_2.p = 6454844767405606854 -- Const: rdfs:label
)
) AS Q_2 -- ?c1:(Q_2.s=>Q_2.X_1)
?label:(Q_2.o=>Q_2.X_2)
LEFT OUTER JOIN
Nodes AS R_1 -- Var: ?c1
ON ( Q_2.X_1 = R_1.hash )
LEFT OUTER JOIN
Nodes AS R_2 -- Var: ?label
ON ( Q_2.X_2 = R_2.hash )
SELECT -- ?c2:(Q_3.s=>Q_3.X_1)
?anyprop:(Q_3.p=>Q_3.X_2)
Q_3.s AS X_1, Q_3.p AS X_2
FROM Quads AS Q_3 -- ex:dst ?c2 ?anyprop "label1"
WHERE ( Q_3.g = -273327510643043486 -- Const: ex:dst
AND Q_3.o = -9201284561348719236 -- Const: "label1"
)
SELECT -- ?c2:(Q_4.s=>Q_4.X_1)
?anyprop:(Q_4.p=>Q_4.X_2)
Q_4.s AS X_1, Q_4.p AS X_2
FROM Quads AS Q_4 -- ex:dst ?c2 ?anyprop "label2"
WHERE ( Q_4.g = -273327510643043486 -- Const: ex:dst
AND Q_4.o = 2153590109465208943 -- Const: "label2"
)
----------------------
| c1 | label |
======================
| ex:src1 | "label1" |
| ex:src2 | "label2" |
----------------------
{noformat}
Note the extra result row. It seems that the inner FILTER has no effect.
The issue seems similar to JENA-1191. I'm using the current (2016-06-10)
3.1.1-SNAPSHOT version.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)