[ 
https://issues.apache.org/jira/browse/JENA-432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13630356#comment-13630356
 ] 

Andy Seaborne edited comment on JENA-432 at 12/24/13 4:39 PM:
--------------------------------------------------------------

I'm not sure what I know more than what I said. The following query:
{noformat}
SELECT ?test ?p1
WHERE {
  ?test ?p1 ?s2.
  FILTER ( ?test = <http://localhost/t1> || ?test = <http://localhost/t2> )
  { SELECT ?s2
    { ?s2 ?p2 ?o2 }
  }
} 
{noformat}
produces 
{noformat}
(project (?test ?s1)
  (disjunction
    (table empty)
    (table empty))) 
{noformat}
instead, I think it should produce 
{noformat}
(project (?test ?p1)
  (disjunction
    (assign ((?test <http://localhost/t1>))
                (join
                        (bgp (triple <http://localhost/t1> ?p1 ?s2))
                        (project (?s2)
                                (bgp (triple ?/s2 ?/p2 ?/o2)))))
        (assign ((?test <http://localhost/t2>))
                (join
                        (bgp (triple <http://localhost/t2> ?p1 ?s2))
                        (project (?s2)
                                (bgp (triple ?/s2 ?/p2 ?/o2)))))
          ))
{noformat}
(that would be the test case)


was (Author: shelsen):
I'm not sure what I know more than what I said. The following query:

SELECT ?test ?p1
WHERE {
  ?test ?p1 ?s2.
  FILTER ( ?test = <http://localhost/t1> || ?test = <http://localhost/t2> )
  { SELECT ?s2
    { ?s2 ?p2 ?o2 }
  }
} 

produces 

(project (?test ?s1)
  (disjunction
    (table empty)
    (table empty))) 

instead, I think it should produce 

(project (?test ?p1)
  (disjunction
    (assign ((?test <http://localhost/t1>))
                (join
                        (bgp (triple <http://localhost/t1> ?p1 ?s2))
                        (project (?s2)
                                (bgp (triple ?/s2 ?/p2 ?/o2)))))
        (assign ((?test <http://localhost/t2>))
                (join
                        (bgp (triple <http://localhost/t2> ?p1 ?s2))
                        (project (?s2)
                                (bgp (triple ?/s2 ?/p2 ?/o2)))))
          ))

(that would be the test case)

> Filter optimization messes up when a nested select is present in the same 
> block
> -------------------------------------------------------------------------------
>
>                 Key: JENA-432
>                 URL: https://issues.apache.org/jira/browse/JENA-432
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: ARQ, Optimizer
>    Affects Versions: Jena 2.10.0
>            Reporter: Simon Helsen
>            Assignee: Andy Seaborne
>             Fix For: Jena 2.10.1
>
>
> The following test query:
> {noformat}
> SELECT ?test ?s1
> WHERE {
>   ?test ?p1 ?o1.
>   FILTER ( ?test = <http://localhost/t1> || ?test = <http://localhost/t2> )  
>   OPTIONAL {
>     SELECT ?s1
>     { ?s1 ?p2 ?o2 }
>   }
> }
> {noformat}
> produces the following plan:
> {noformat}
> (project (?test ?s1)
>   (disjunction
>     (table empty)
>     (table empty)))
> {noformat}
> Something goes wrong with the FILTER expansion. As a workaround, we observed 
> that the following variation:
> {noformat}
> SELECT ?test ?s1
> WHERE {
>   { ?test ?p1 ?o1.
>     FILTER ( ?test = <http://localhost/t1> || ?test = <http://localhost/t2> ) 
>  
>   }
>   OPTIONAL {
>     SELECT ?s1
>     { ?s1 ?p2 ?o2 }
>   }
> }
> {noformat}
> produces the correct plan:
> {noformat}
> (project (?test ?s1)
>   (leftjoin
>     (disjunction
>       (assign ((?test <http://localhost/t1>))
>         (bgp (triple <http://localhost/t1> ?p1 ?o1)))
>       (assign ((?test <http://localhost/t2>))
>         (bgp (triple <http://localhost/t2> ?p1 ?o1))))
>     (project (?s1)
>       (bgp (triple ?s1 ?/p2 ?/o2)))))
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to