Skip to content

Commit a0ccbd5

Browse files
committed
Add 'row in scope' approach
1 parent 0f7b66d commit a0ccbd5

File tree

1 file changed

+75
-18
lines changed

1 file changed

+75
-18
lines changed

spec/index.html

Lines changed: 75 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10429,7 +10429,7 @@ <h3>Evaluation Semantics</h3>
1042910429
<section>
1043010430
<h3>Values Insertion and `EXISTS`</h3>
1043110431
<div class="ednote">
10432-
<p>The following subsections contain draft of material for a revised
10432+
<p>The following subsections contain draft material for a revised
1043310433
"`exists`" operation.
1043410434
</p>
1043510435
<p>
@@ -10444,7 +10444,10 @@ <h4>Syntax Restriction</h4>
1044410444
This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES`
1044510445
clause, and variables introduced by `AS` in `GROUP BY`.
1044610446
</blockquote>
10447-
<p>Extend the "in-scope" rules to include the variables in-scope from the current row:</p>
10447+
<p>
10448+
Extend the "in-scope" rules to include the possible
10449+
variables that are in-scope for the current row:
10450+
</p>
1044810451
<table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px">
1044910452
<tbody>
1045010453
<tr>
@@ -10458,10 +10461,15 @@ <h4>Syntax Restriction</h4>
1045810461
</tr>
1045910462
</tbody>
1046010463
</table>
10461-
<p class="note">
10462-
This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10463-
do not conflict with values assigned to variables within the pattern.
10464-
</p>
10464+
<div class="note">
10465+
<p>
10466+
This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10467+
do not conflict with values assigned to variables within the pattern.
10468+
</p>
10469+
<p>
10470+
This operation is performed as part of query parsing.
10471+
</p>
10472+
</div>
1046510473
</section>
1046610474
<section>
1046710475
<h4>Remapping</h4>
@@ -10514,39 +10522,88 @@ <h4>Remapping</h4>
1051410522
Replacements may happen several times, depending on recursive order
1051510523
but each time a replacement is made, the variable not used anywhere else.
1051610524
</p>
10517-
10518-
<p class="note">
10519-
A variable inside a project expression that is not in the variables projected
10520-
is not affected by the values insertion operation because it is renamed apart.
10521-
</p>
10525+
10526+
<div class="note">
10527+
<p>
10528+
A variable inside a project expression that is not in the variables projected
10529+
is not affected by the values insertion operation because it is renamed apart.
10530+
</p>
10531+
<p>
10532+
This operation is as part of the <a href="#sparqlQuery">translation to the SPARQL
10533+
algebra</a>.
10534+
</p>
10535+
</div>
1052210536
</section>
1052310537
<section>
1052410538
<h4>Values Insertion</h4>
10539+
<p>
10540+
Alternative 1: rewrite the algebra during
10541+
<a href="#sparqlQuery">translation to the SPARQL algebra</a>
10542+
to include a function that evaluates to the current row.
10543+
</p>
10544+
1052510545
<div class="defn">
1052610546
<div>
10527-
<b>Definition: <span id="defn_valuesinsertion" name="defn_valuesinsertion">Values Insertion</span></b>
10547+
<b>Definition: <span id="defn_correlate" name="defn_correlate">Values In Scope</span></b>
1052810548
<p>
10529-
Define the Values Insertion function `ValuesInsert(X, μ)`
10549+
Define the function `BindingInScope()`.
10550+
Evaluation of `BindingInScope()` results in a table of one row,
10551+
being the current binding of the enclosing filter.
1053010552
</p>
10531-
<pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10553+
</div>
10554+
</div>
1053210555

10556+
<div class="defn">
10557+
<div>
10558+
<b>Definition: Access to the current binding</b>
10559+
<p>
10560+
During <a href="#sparqlQuery">translation to the SPARQL algebra</a>
10561+
</p>
10562+
<pre>
1053310563
Replace each occurence of `Y` in X where `Y` is one of
1053410564
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
1053510565
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
1053610566
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
1053710567
<a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10538-
with `join(Y, Table(μ))`.</pre>
10539-
10568+
with `join(Y, BindingInScope())`.</pre>
10569+
</div>
10570+
<div class="note">
10571+
c.f. section <a href="#sparqlTranslateGraphPatterns">Translate Graph Patterns</a>
10572+
where an empty basic graph pattern start any
10573+
<a href="#rGroupGraphPattern">GroupGraphPattern</a>.
10574+
It happens before the <a href="#sparqlSimplification">simplification step</a>.
1054010575
</div>
10541-
<p>@@ rename as ???correllate</p>
1054210576
</div>
1054310577

1054410578
<div class="example">
1054510579
<p>
1054610580
Examples
1054710581
</p>
1054810582
</div>
10583+
10584+
<p>
10585+
Alternative 2: rewrite the algebra during execution. This corresponds to the
10586+
<a href="https://github.com/w3c/sparql-dev/blob/main/SEP/SEP-0007/sep-0007.md">original SEP-0007 proposal</a>.
10587+
</p>
10588+
<div class="defn">
10589+
<div>
10590+
<b>Definition: <span id="defn_valuesinsertion" name="defn_valuesinsertion">Values Insertion</span></b>
10591+
<p>
10592+
Define the Values Insertion function `ValuesInsert(X, μ)`
10593+
</p>
10594+
<pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10595+
10596+
Replace each occurence of `Y` in X where `Y` is one of
10597+
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
10598+
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
10599+
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
10600+
<a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10601+
with `join(Y, Table(μ))`.</pre>
10602+
10603+
</div>
10604+
</div>
1054910605
</section>
10606+
1055010607
<section>
1055110608
<h4>Evaluation of EXISTS</h4>
1055210609
<div class="defn">
@@ -10556,7 +10613,7 @@ <h4>Evaluation of EXISTS</h4>
1055610613
define the Evaluation of Exists `exists(X)`
1055710614
</p>
1055810615
<pre>exists(X) = true
10559-
if eval( D(G), ValuesInsert(PrjMap(X), μ) )
10616+
if eval( D(G), ValuesInScope(PrjMap(X)), μ)
1056010617
is a non-empty solution sequence.
1056110618
exists(X) = false otherwise</pre>
1056210619
</div>

0 commit comments

Comments
 (0)