You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (JIRA)" <ji...@apache.org> on 2014/03/15 22:04:43 UTC

[jira] [Resolved] (JENA-653) Filter Placement into union pushes down whole filter but this fails in a sequence.

     [ https://issues.apache.org/jira/browse/JENA-653?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andy Seaborne resolved JENA-653.
--------------------------------

       Resolution: Fixed
    Fix Version/s: Jena 2.11.2

> Filter Placement into union pushes down whole filter but this fails in a sequence.
> ----------------------------------------------------------------------------------
>
>                 Key: JENA-653
>                 URL: https://issues.apache.org/jira/browse/JENA-653
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: ARQ
>    Affects Versions: Jena 2.11.1
>            Reporter: Andy Seaborne
>            Assignee: Andy Seaborne
>             Fix For: Jena 2.11.2
>
>         Attachments: Q.rq, data.ttl
>
>
> The filter placement method of pushing into both arms only works when the filter is directly over the union. If the filter is further out, and for filter expressions that do not involve variables in the union arms, it should be left outside as it may be applied elsewhere later.
> This is shown in sequence where the union is before some pattern that does bind the variable.
> Example - the key feature is that the {{union}} is first and is joined to a BGP with the union on the LHS and BGP on the RHS. If the join order is reversed, then a reasonable and corect optimization is performed.
> {noformat}
> PREFIX  ex:   <http://ex.org/>
> PREFIX  rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> SELECT  *
> WHERE
>   {   { ?item rdf:type ex:type_a }
>     UNION
>       { ?item rdf:type ex:type_b }
>     ?item ex:label ?label
>     FILTER ( str(?label) = "a" )
>   }
> {noformat}
> Algebra, after join strategy, before filter placement. The joion style is a {{sequence}}:
> {noformat}
> (prefix ((ex: <http://ex.org/>)
>          (rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>))
>   (filter (= (str ?label) "a")
>     (sequence
>       (union
>         (bgp (triple ?item rdf:type ex:type_a))
>         (bgp (triple ?item rdf:type ex:type_b)))
>       (bgp (triple ?item ex:label ?label)))))
> {noformat}
> which is optimzed (wrongly) as:
> {noformat}
> (prefix ((ex: <http://ex.org/>)
>          (rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>))
>   (sequence
>     (union
>       (filter (= (str ?label) "a")
>         (bgp (triple ?item rdf:type ex:type_a)))
>       (filter (= (str ?label) "a")
>         (bgp (triple ?item rdf:type ex:type_b))))
>     (bgp (triple ?item ex:label ?label))))
> {noformat}
> The  {{(filter (= (str ?label) "a")}} is applied on the {{union}}, not the later {{(bgp (triple ?item ex:label ?label))))}}.
> The problem is in the relationship of {{sequence}} and {{union}}. The {{union}} can't be treated isolation with the current design.  Either the {{union}} needs a better placement calculated, or failing that (less preferrable), a flag to change the way filters are pushed own in union depending on nesting context.



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