0

My intention is to

  1. Parse a SPARQL query to the ARQ Algebra.
  2. Get some work done.
  3. Parse the ARQ Algebra back to SPARQL query.

Approach below seems to work as expected for SELECT queries, but fails for ASK and CONSTRUCT queries. I will highly value your help on this one. :)

Op opRoot = Algebra.compile(QueryFactory.create(sparqlQueryStr));

OpWalker.walk(opRoot, visitor);

OpAsQuery.asQuery(opRoot).serialize();
RedCrusaderJr
  • 350
  • 1
  • 12
  • 1
    `OpAsQuery.asQuery` produces SELECT queries - in essence, it works on the WHERE clause. The SELECT project and variable bindings are alegebra operations. You'll need to additionally convert to CONSTRUCT or ASK. These have a "results presentation" stage that isn't part of the algebra. – AndyS Nov 22 '22 at 12:40
  • Does Jena have a built-in way to do that conversion? – RedCrusaderJr Nov 22 '22 at 12:42
  • 1
    No. You'll need to additionally convert to CONSTRUCT or ASK based on the query type (the algebra does not know the query type nor the construct template). – AndyS Nov 22 '22 at 13:24

0 Answers0