The syntax error was correct even in the current stable version

The problem was that the code for converting from an algebra back into a
query usually puts top level BIND as project expressions which in most
cases is semantically equivalent to the original query.  However when
there is a GROUP BY present it needs to recreate the BIND as an actual
BIND or you get the variable scope error.

In algebra terms a project expression and a BIND at the top level of the
query pattern are semantically equivalent bar the above proviso about
interaction with GROUP BY

Rob

On 4/1/13 7:47 PM, "Diogo FC Patrao" <[email protected]> wrote:

>Hello Rob
>
>Should now be fixed, build from latest Trunk or wait 24 hrs or so for the
>> snapshot to get build and deployed by the Apache build server
>>
>
>* THANKS a million * ! I'm running a couple of experiments for my PhD
>thesis, and was getting the excuses done, for that bug messed up part of
>my
>data. Now I can get everything right. Thanks, thanks.
>
>
>> What version of ARQ are you using to do the OpAsQuery? I assume
>> 2.10.1-SNAPSHOT since turning this type of query from its algebra back
>> into a query only very recently became possible.  Previously the BIND
>> would have been lost completely when converting back from an algebra to
>>a
>> query.
>>
>
>The jar file says "2.10.0", I just downloaded the latest stable version.
>
>
>> Also is there a reason you are using ARQ 2.8.8 in your system?  That's
>> very out of date (about 2 years so) now.
>>
>
>well, I'm running this experiment for one year and two months now, and
>just
>copied the binaries and stuff that were working. TLDR: lazy.
>
>anyway, 2.10.0 ARQ yielded the same error.
>
>However, should defining an alias on the query head allow referring to it
>elsewhere? Are alias and BINDs really equivalent? MySQL have this
>behaviour, but not Oracle.
>
>Thanks (again).
>
>dfcp
>
>
>
>
>> Andy - The report states that the query is passed off to a system
>>running
>> 2.8.8, even with this fix did ARQ support BIND syntax that far back?
>>I.e.
>> will this fix just move the error elsewhere?
>>
>> Rob
>>
>>
>>
>> On 4/1/13 12:42 PM, "Andy Seaborne" <[email protected]> wrote:
>>
>> >Hi there,
>> >
>> >Thanks for the report. I've captured this as:
>> >
>> >https://issues.apache.org/jira/browse/JENA-429
>> >
>> >       Andy
>> >
>> >On 31/03/13 21:11, Diogo FC Patrao wrote:
>> >> 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#documentDateOfCreati
>> >>on>
>> >> ?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