Aldo,

I've reproduced the bug, will fix it.
Thank you for the report (and for your patience while I was unable to
understand the problem).

Best Regards,

Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com

On Thu, 2009-10-15 at 06:30 -0300, Aldo Bucchi wrote:
> Hi Ivan,
> 
> On Thu, Oct 15, 2009 at 6:08 AM, Ivan Mikhailov
> <imikhai...@openlinksw.com> wrote:
> > Hello Aldo,
> >
> >> Isn't there any way that the compiler can detect which variables are
> > being referenced  in the select projections part?
> >
> > It detects, but you write "select ?text", not "select ?s ?text" in 
> > subqueries.
> 
> But try it:
> 
> select distinct ?text where {
>  { select ?text where {?s rdfs:label ?text} } union { select ?text
> where {?s rdfs:comment ?text} }
> } limit 10
> 
> You'll get an error as well:
> http://bit.ly/3vNARm
> 
> >
> > Like in SQL, Datalog and other similar languages, variables inside
> > subexpressions are not in the surrounding scope, you should place ?s to
> > the inner SELECT result-list to refer to it at the upper level.
> > Similarly, ?text is usable not because it appears in { ?s
> > rdfs:label ?text } but because it is found after SELECT. It could be,
> > say,
> > { select (?inner_s) as ?s (?inner_text) as ?text
> > where {?inner_s rdfs:label ?inner_text} }
> > to provide values for ?s and ?text even if there are no such variables
> > in subquery at all.
> 
> Yes, this part is clear.
> The way I see it is that all variables projected ( select'ed ) by the
> inner expression become "potentially" available for the outer
> expression.
> This only happens IF the outer expression binds them as well in the
> conditions clause. ( it doesn't suffice for it to "select" them ).
> 
> It is that IF that makes me mad every now and then.
> 
> >
> > Next version of SPARQL compiler may contain special check for
> > "namesakes" in different scopes, to keep the author warned.
> 
> The author says: "All warnings are welcome!" ;)
> 
> Regards,
> A
> 
> >
> > Best Regards,
> > Ivan.
> >
> > On Thu, 2009-10-15 at 05:33 -0300, Aldo Bucchi wrote:
> >> Hi,
> >>
> >> There is a general caveat when building SPARQL Unions of Subqueries in
> >> Virtuoso which I believe is unnecessary.
> >>
> >> The following query works fine.
> >>
> >> select distinct ?s ?text where {
> >>   { ?s rdfs:label ?text } union { ?s rdfs:comment ?text }
> >> } limit 10
> >>
> >> But assume I want to complicate it a bit by using subqueries ( in this
> >> case it makes no sense, but there are definitely use cases for this,
> >> like combing results of complex queries )
> >>
> >> select distinct ?s ?text where {
> >>   { select ?text where {?s rdfs:label ?text} } union { select ?text
> >> where {?s rdfs:comment ?text} }
> >> } limit 10
> >>
> >> The latter query will yield an error:
> >>
> >> 37000 Error SP031: SPARQL compiler: Variable 's' is used in the query
> >> result set but not assigned
> >>
> >> So, it follows that I need to bind the variables at least once in the
> >> outer pattern.
> >> Fine, I can do that:
> >>
> >> select distinct ?s ?text where {
> >>   ?s ?p ?text .
> >>   { select ?text where {?s rdfs:label ?text} } union { select ?text
> >> where {?s rdfs:comment ?text} }
> >> } limit 10
> >>
> >> And it works ;)
> >>
> >> But, here's the observation: Why do I HAVE to declare the variables 
> >> outside?
> >> Isn't there any way that the compiler can detect which variables are
> >> being referenced  in the select projections part?
> >>
> >> When dealing with complex queries I usually find myself writing dummy
> >> BGPs, for example:
> >>
> >> ?interestingSubject ?xx1 ?xx2 .
> >> ?xx3 ?xx4 ?interestingObject .
> >> { subquery1... } union { subquery2...} union {subquery3...}
> >>
> >> Will enabling this "automatically" introduce ambiguity?
> >>
> >> Regards,
> >> A
> >>
> >>
> >
> >
> 
> 
> 
> -- 
> Aldo Bucchi
> skype:aldo.bucchi
> http://www.univrz.com/
> http://aldobucchi.com/
> 
> PRIVILEGED AND CONFIDENTIAL INFORMATION
> This message is only for the use of the individual or entity to which it is
> addressed and may contain information that is privileged and confidential. If
> you are not the intended recipient, please do not distribute or copy this
> communication, by e-mail or otherwise. Instead, please notify us immediately 
> by
> return e-mail.
> 
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Virtuoso-users mailing list
> Virtuoso-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/virtuoso-users


Reply via email to