jena icon indicating copy to clipboard operation
jena copied to clipboard

QueryBuilder should generate query syntax trees that correspond to parser output.

Open afs opened this issue 1 year ago • 0 comments

Version

5.0.0

Feature

See #2153 and #2155 .

Even if the algebra generator is changed to cope with the non-parser AST generated by querybuilder (PR #2155), should the querybuilder try to generate parser-compatible ASTs?

When used over the wire, a query is always in string form.

Example (Jena 4.10.0):

    public static void querybuilderOutput() {
            SelectBuilder selectBuilder = new SelectBuilder();
            selectBuilder.addFilter(selectBuilder.makeExpr("true"));
            Query query = selectBuilder.build();
            System.out.println(query);
            Query query2 = QueryFactory.create(query.toString());
            System.out.println(query2);
            System.out.println("Parsed builder output equals input? "+query.equals(query2));
    }

Output:

SELECT  *
WHERE
  { FILTER ( true )}

SELECT  *
WHERE
  { FILTER ( true ) }

Parsed builder output equals input? false

Note the slight difference in the query strings due to the presence of the ElementGroup in the second, parsed case, which isn't in querybuilder form.

The query patterns of the WHERE clause are:

  • querybuilder : ElementFilter(true)
  • parser : ElementGroup ( ElementFilter(true) ).

Are you interested in contributing a solution yourself?

None

afs avatar Jan 05 '24 13:01 afs