QueryBuilder should generate query syntax trees that correspond to parser output.
- Dominant language
- Java
- Stars
- 1.4k
- Forks
- 712
- Avg merge
- 15h 41m
- Merged PRs (30d)
- 53
Description
### 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):
```java
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
Contributor guide
Research direction
Start with SelectBuilder and QueryBuilder, then compare the builder output with QueryFactory.create(query.toString()) as shown in the Jena 4.10.0 example. Inspect how the algebra generator and parser represent the WHERE clause, especially ElementFilter versus ElementGroup; done means builder-generated trees match parser output and the equality example succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100