openlink / virtuoso-opensource

Virtuoso is a high-performance and scalable Multi-Model RDBMS, Data Integration Middleware, Linked Data Deployment, and HTTP Application Server Platform
http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/
Other
848 stars 214 forks source link

Error in computing numeric expressions when a filter is applied in a SPARQL query #205

Open pamichel opened 10 years ago

pamichel commented 10 years ago

Hi,

If I run the following SPARQL

select ?isoform ?str ?dom ?s1 ?s2 ?d1 ?d2 ?o1 ?o2 ?overlap where { 
  GRAPH <http://pam/test/b>
  { 
    values ?isoform { isoform:NX_Q9HAU5-1 } .
    ?isoform :region ?str .
    ?str a :3dStructure ; :start ?s1 ; :end ?s2 .
    ?isoform :region ?dom .
    ?dom a :CoiledCoilRegion ; :start ?d1 ; :end ?d2 .
    bind( if(?d1>?s1, ?d1, ?s1) as ?o1).
    bind( if(?d2<?s2, ?d2, ?s2) as ?o2) . 
    bind (?o2 - ?o1 as ?overlap) .
  }
}

I get the following correct result: screen shot 2014-06-20 at 3 08 55 pm

If I now just add a filter on the ?overlap variable vale, then the value of ?o1 and subsequently the value of ?overlap is wrong for one of the row of the solution returned.

select ?isoform ?str ?dom ?s1 ?s2 ?d1 ?d2 ?o1 ?o2 ?overlap where { 
  GRAPH <http://pam/test/b>
  { 
    values ?isoform { isoform:NX_Q9HAU5-1 } .
    ?isoform :region ?str .
    ?str a :3dStructure ; :start ?s1 ; :end ?s2 .
    ?isoform :region ?dom .
    ?dom a :CoiledCoilRegion ; :start ?d1 ; :end ?d2 .
    bind( if(?d1>?s1, ?d1, ?s1) as ?o1).
    bind( if(?d2<?s2, ?d2, ?s2) as ?o2) . 
    bind (?o2 - ?o1 as ?overlap) .
    filter (?overlap>10)
  }
}

Result after adding the filter: screen shot 2014-06-20 at 3 18 05 pm

The wrong values are in red. Note that removing the variable BINDings and writing instead a complex expression in the filter with the variables ?s1 ?s2 ?d1 ?d2 causes the same error. I use virtuoso opensource Version 07.10.3208-pthreads for Linux as of Apr 10 2014

Below is the code to insert the data so that you can reproduce the problem. Thanks in advance Pierre-André

prefix rdf:         <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix :            <http://nextprot.org/rdf#> 
prefix annotation:  <http://nextprot.org/rdf/annotation/> 
prefix isoform:     <http://nextprot.org/rdf/isoform/> 

INSERT DATA { GRAPH <http://pam/test/b> {

annotation:NX_Q9HAU5-1-AN_Q9HAU5_000319 rdf:type    :CoiledCoilRegion ;
    :end    134 ;
    :start  54 .
annotation:NX_Q9HAU5-1-AN_Q9HAU5_000320 rdf:type    :CoiledCoilRegion ;
    :end    559 ;
    :start  487 .
annotation:NX_Q9HAU5-1-AN_Q9HAU5_000600 rdf:type    <http://nextprot.org/rdf#3dStructure> ;
    :end    1015 ;
    :start  768 .
annotation:NX_Q9HAU5-1-AN_Q9HAU5_000601 rdf:type    <http://nextprot.org/rdf#3dStructure> ;
    :end    1198 ;
    :start  1105 .
annotation:NX_Q9HAU5-1-AN_Q9HAU5_000602 rdf:type    <http://nextprot.org/rdf#3dStructure> ;
    :end    757 ;
    :start  455 .
annotation:NX_Q9HAU5-1-AN_Q9HAU5_000603 rdf:type    <http://nextprot.org/rdf#3dStructure> ;
    :end    486 ;
    :start  121 .
isoform:NX_Q9HAU5-1 :region annotation:NX_Q9HAU5-1-AN_Q9HAU5_000602 ,
        annotation:NX_Q9HAU5-1-AN_Q9HAU5_000319 ,
        annotation:NX_Q9HAU5-1-AN_Q9HAU5_000603 ,
        annotation:NX_Q9HAU5-1-AN_Q9HAU5_000320 ,
        annotation:NX_Q9HAU5-1-AN_Q9HAU5_000600 ,
        annotation:NX_Q9HAU5-1-AN_Q9HAU5_000601 .
}}
HughWilliams commented 9 years ago

Hi Pierre,

I have been able to recreate and will check with development when they expect to look into this ...