Andy Seaborne created JENA-1235:
-----------------------------------

             Summary: Disjunction expansion then blocks filter placement.
                 Key: JENA-1235
                 URL: https://issues.apache.org/jira/browse/JENA-1235
             Project: Apache Jena
          Issue Type: Bug
          Components: ARQ
    Affects Versions: Jena 3.0.0
            Reporter: Andy Seaborne
            Assignee: Andy Seaborne


{noformat}
    public static void main(String ...args) {
        String qs = StrUtils.strjoinNL
            ("PREFIX  :     <http://example.org>"
            ,""
            ,"SELECT *"
            ,"{"
            ,"    FILTER ( ( ?var3 = 'ABC' ) || ( ?var3 = 'XYZ' ) )"
            ,"    FILTER ( regex(?var4, 'pat1') && ?VAR!=123)"
            ,"    ?var2  :p1  ?var4 ;"
            ,"           :p2  ?var3 ."
            ,"}"
            ) ;
        Query query = QueryFactory.create(qs);
        Op op = Algebra.compile(query) ;
        Op op1 = Algebra.optimize(op) ;
        System.out.println(op1); 
    }
{noformat}
gives this where the regex has not been pushed in:
{noformat}
(filter (exprlist (regex ?var4 "pat1") (!= ?VAR 123))
  (disjunction
    (assign ((?var3 "ABC"))
      (bgp
        (triple ?var2 <http://example.orgp1> ?var4)
        (triple ?var2 <http://example.orgp2> "ABC")
      ))
    (assign ((?var3 "XYZ"))
      (bgp
        (triple ?var2 <http://example.orgp1> ?var4)
        (triple ?var2 <http://example.orgp2> "XYZ")
      ))))
{noformat}

as in: (note the {{(!= ?VAR 123)}} remains outside as it is not used. This is 
more about being tidy).

{noformat}
(filter (!= ?VAR 123)
  (disjunction
    (assign ((?var3 "ABC"))
      (sequence
        (filter (regex ?var4 "pat1")
          (bgp (triple ?var2 <http://example.orgp1> ?var4)))
        (bgp (triple ?var2 <http://example.orgp2> "ABC"))))
    (assign ((?var3 "XYZ"))
      (sequence
        (filter (regex ?var4 "pat1")
          (bgp (triple ?var2 <http://example.orgp1> ?var4)))
        (bgp (triple ?var2 <http://example.orgp2> "XYZ"))))))
{noformat}





--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to