Re: another problem with proposal B

good evening;
[resent, as i suspect the other originating address will be rejected.]

> On 2017-03-10, at 15:03, Andy Seaborne <andy@apache.org> wrote:
> 
> [about queries from patel-schneider, to call attention to restrictions which apply to environment (aka multi-set) extension operations and to suggest that the constructs were - or now become invalid.]

i do not believe those interpretations to follow from the language specification and if proposal b suggests that they should, it is not obvious, how and, even if that is explained, that the proposal should be permitted.

the combinations appear to have been

>> Here is another problem with proposal B.
>> 
>> Both of the following queries are syntactically valid but have undefined results.
>> 
>> SELECT ?x WHERE {
>> BIND ( ex:a AS ?x )
>> FILTER EXISTS { SELECT (ex:b AS ?x) WHERE { } }
>> }

a null environment extended with ?x to which a filter is applied in which a null environment is extended with ?x in the select expression projection clause.
this is and should remain a legal construct.

>> 
>> SELECT ?x WHERE {
>> BIND ( ex:a AS ?x )
>> FILTER EXISTS { SELECT ?x WHERE { BIND (ex:b AS ?x) } }
>> }

a null environment extended with ?x to which a filter is applied in which a null environment is extended with ?x in the select expression where clause.
this is and should remain a legal construct.
that is, it should not behave differently than these variations:

* (run-sparql "
prefix ex: <http://example.org/>
SELECT ?x WHERE {
BIND ( ex:a AS ?x )
{ SELECT (ex:a AS ?x) WHERE { } }
}" :repository-id "james/test")

((<http://example.org/a>))
(?::|x|)
#<QUERY [717d87ee-7c66-a34f-a3f3-000000000000/NIL, select@COMPLETE, james/test@HEAD] {101AC676EB}>
T
* (run-sparql "
prefix ex: <http://example.org/>
SELECT ?x WHERE {
BIND ( ex:a AS ?x )
{ SELECT (ex:a AS ?x) (ex:b AS ?x) WHERE { } }
}" :repository-id "james/test")

debugger invoked on a SIMPLE-ERROR in thread
#<THREAD "main thread" RUNNING {100A686503}>:
 Duplicate bindings: (x <http://example.org/a>) . ((x <http://example.org/b>))

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
 0: [CONTINUE] Retry assertion.
 1: [ABORT   ] Exit debugger, returning to top level.

(SB-KERNEL:ASSERT-ERROR (NOT (ORG.DATAGRAPH.SPOCQ.SPARQL-1-0-2::IS-DUPLICATE-BINDING ORG.DATAGRAPH.SPOCQ.SPARQL-1-0-2::BINDING REST)) (((ORG.DATAGRAPH.SPOCQ.SPARQL-1-0-2::IS-DUPLICATE-BINDING ORG.DATAGRAPH.SPOCQ.SPARQL-1-0-2::BINDING REST) T)) NIL "Duplicate bindings: ~a . ~a" (?::|x| <http://example.org/a>) ((?::|x| <http://example.org/b>)))
0] 
* 

> 
> These are redefining a variable already  in-scope for the FILTER so are not allowed.

> Variables from the current row of the filter are fixed throughout the EXISTS evaluation and can not be refined.
> 
> It applies statically to any variable potentially bound (scoping rules - so applies to
> OPTIONAL { ... ?x ... } FILTER EXISTS { BIND (ex:b AS ?x) }
> ). This is the same process as already exists in SPARQL, with the change that the in-scope set is seeded with the current row.
> 
>> 
>> The following query however does have defined results
>> 
>> SELECT ?x WHERE {
>> BIND ( ex:a AS ?x )
>> FILTER EXISTS { SELECT ?y WHERE { BIND (ex:b AS ?x) } }
>> }

a null environment extended with ?x to which a filter is applied in which a null environment is extended with ?x in the select expression where clause, but just ?y is projected.
in an run-time which tolerates undefined variables in that situation, this is and should remain a legal construct.


>> 
>> This problem is different from that that added the disallowing of binding to
>> filter variables at the top level of the EXISTS argument as in
>> 
>> SELECT ?x WHERE {
>> BIND ( ex:a AS ?x )
>> FILTER EXISTS { BIND (ex:b AS ?x) }
>> }

a null environment extended with ?x to which a filter is applied in which a null environment is extended with ?x.
that is, as above, as in

* (pprint-sse (parse-sparql "
prefix ex: <http://example.org/>
SELECT ?x WHERE {
BIND ( ex:a AS ?x )
FILTER EXISTS { BIND (ex:b AS ?x) }
}"))
(select
  (filter (extend (table unit) ?x <http://example.org/a>) (exists (extend (table unit) ?x <http://example.org/b>)))
  (?x))
*

this is and should remain a legal construct.
> 
> I don't see it as different. The "Limitations on Assignment" apply deeply - as they do for any SPARQL query already.

>> The translation to the SPARQL algebra may not produce any place for values
>> insertion to take place.  This is due to the simplification step in
>> 18.2.2.8.
>> 
>> For example, the graph pattern
>> 	{ VALUES ?x ( ex:b ) }
>> is translated into an SPARQL algebra expression containing only a multiset,
>> something like
>> 	{{ (x,ex:b) }}
>> This results in counterintuitive behaviour on queries like
>> 
>> SELECT ?x WHERE {
>> BIND ( ex:a AS ?x )
>> FILTER EXISTS { VALUES ?x ( ex:b ) }
>> }
> 
> This query is illegal because it attempts to reassign a variable already a bound in the current row.
> 
> If it were a different name, ?z say, then its just fixed data independent of the current row.
> 
> As soon as the query adds anything that can influenced by the current row, the current row variables will be available.

a null environment extended with ?x to which a filter is applied in which an environment is constructed over the variable ?x.
if this were
>> 
>> SELECT ?x WHERE {
>> BIND ( ex:a AS ?x )
>> { VALUES ?x ( ex:b ) }
>> }

it would be and should remain a legal  construct.
that in contrast to
>> 
>> SELECT ?x WHERE {
>> { VALUES ?x ( ex:b ) }
>> BIND ( ex:a AS ?x )
>> }

which is not legal.

best regards, from berlin,

Received on Friday, 10 March 2017 17:36:38 UTC