Re: another problem with Proposal B

On 18/04/17 19:24, Peter F. Patel-Schneider wrote:
> [Second half only.]
>
>>> SELECT ?this WHERE {
>>>   ?this a ex:good .
>>>   FILTER EXISTS { { SELECT * WHERE { } }
>>>                   BIND ( ?this AS ?that )
>>>                   ?that a ex:bad } }
>>>
>>> peter
>>>
>>
>> Simplification applies after syntax parsing, before evaluation.
>>
>> Inner "SELECT * {}" is a project of no variables of the unit table which is
>> left as-is.  So no simplification.
>>
>> 18.2.4.4
>> "The set PV is used later for projection."
>>
>> 18.2.5.2 Projection
>> """
>> The set of projection variables, PV, was calculated in the processing of
>> SELECT expressions.
>>
>>     M := Project(M, PV)
>> """
>>
>> There is something to account for in SELECT * but it's not simplification.
>>
>>     Andy
>
>
> As far as I can tell the inner select is translated (see last example in
> 18.2.3) as
>   ToMultiSet(Project(Z,{}))
>
> The argument to EXISTS is translated (19.2.2.6) as
>   Join( Extend(Join(Z,ToMultiSet(Project(Z,{}))),?that,?this),
>      BGP(?that rdf:type ex:bad )
>
> Simplification (18.2.2.8) then results in
>   Join( Extend(ToMultiSet(Project(Z,{})),?that,?this),
>      BGP(?that rdf:type ex:bad) )

and the Z is not in a join.

>
> So the EXISTS is translated to
>   exists(
>     Join( Extend(ToMultiSet(Project(Z,{})),?that,?this),
>        BGP(?that rdf:type ex:bad) ) )
>
> Evaluation of the EXISTS with ?this mapped to ex:i proceeds by first doing
> the replacement, which ends up with something like
>   Join( Extend(ToMultiSet(Project(Join(Z,{{?this,ex:i}}),{})),?that,?this),
                                         ^^^
Simplification happened after the query was parsed, as the algebra was 
created and does not apply again during evaluation.

It should be that

project -> {{?this,ex:i}}

except for the issue noted about "SELECT *"

then BIND ( ?this AS ?that ) happens.
then join with BGP(?that rdf:type ex:bad)

>      Join(BGP(?that rdf:type ex:bad),{{?this,ex:i}}) )
> This is evaluated to
>   Join( Extend({{}},?that,?this),
>      Join(BGP(?that rdf:type ex:bad),{{?this,ex:i}}) )
> and then to
>   Join( {{}},
>      Join(BGP(?that rdf:type ex:bad),{{?this,ex:i}}) )
>
> The BIND then ends up not having any effect because ?this doesn't have a
> binding when it is evaluated, due simplification removing the place where
> the FILTER variables might have been joined in.

I don't see where such a simplification is happening.
It's the fact SELECT * is calculated without regard to the current row.

When "SELECT *" includes ?this, the inner BGP has the current row added.

"SELECT * {}" does not have a join.

>
> peter
>

(prefix ((: <http://example/>)
          (rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>))
   (project (?this)
     (filter (exists
                (join
                  (extend ((?that ?this))
                    (project {}
                      (table unit)))
                  (bgp (triple ?that rdf:type <::ex:bad>))))
       (bgp (triple ?this rdf:type <::ex:good>)))))

for the EXISTS part:

(join
   (extend ((?that ?this))
     (project {}
       (table unit))
   (bgp (triple ?that rdf:type <::ex:bad>))
)

BIND extends the graph pattern (syntactically - it's gathered up in 
syntax->algebra) before it.

Received on Friday, 21 April 2017 19:55:47 UTC