Hello

I was performing a simple test with OpAsQuery:

Here is the original query:

PREFIX : <http://www.cipe.accamargo.org.br/ontologias/h2tc.owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX mylib: <java:dateadd.lib.pkgfor.arq.>

    SELECT ?yearmonth ( count(?document) as ?total )
    WHERE
    {
        ?document a :Document;
                 :documentDateOfCreation ?date ;
                 :documentType "exam results" .
        BIND( mylib:DateFormat( xsd:string(?date), "yyyy-MM" ) as
?yearmonth )
    } group by ?yearmonth

Then I ran the code below, that compile the algebra then render the query
again.

Query query = QueryFactory.create( that_query_above,
Syntax.syntaxSPARQL_11);

Op op = Algebra.compile(query);

System.out.println(OpAsQuery.asQuery(op));

The result is below:

SELECT  (<java:dateadd.lib.pkgfor.arq.DateFormat>(<
http://www.w3.org/2001/XMLSchema#string>(?date), "yyyy-MM") AS ?yearmonth)
(count(?document) AS ?total)

WHERE

  { ?document <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <
http://www.cipe.accamargo.org.br/ontologias/h2tc.owl#Document> .

    ?document <
http://www.cipe.accamargo.org.br/ontologias/h2tc.owl#documentDateOfCreation>
?date .

    ?document <
http://www.cipe.accamargo.org.br/ontologias/h2tc.owl#documentType> "exam
results"

  }

GROUP BY ?yearmonth

However, this is not a valid query; notice that the BIND has gone, it
somehow turned to a alias on query's head.

ARQ 2.8.8. upon receiving this query, yields the error:

Variable used when already in-scope: ?yearmonth in
(<java:dateadd.lib.pkgfor.arq.DateFormat>(xsd:string(?date), "yyyy-MM") AS
?yearmonth)

Is that a bug on ARQ or OpAsQuery? Or anything else?

Thanks!

--
diogo patrĂ£o

Reply via email to