Skip to content

Commit a2db77b

Browse files
committed
Add 'row in scope' approach
1 parent 57d1158 commit a2db77b

File tree

1 file changed

+76
-19
lines changed

1 file changed

+76
-19
lines changed

spec/index.html

Lines changed: 76 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10472,7 +10472,7 @@ <h3>Evaluation Semantics</h3>
1047210472
<section>
1047310473
<h3>Values Insertion and `EXISTS`</h3>
1047410474
<div class="ednote">
10475-
<p>The following subsections contain draft of material for a revised
10475+
<p>The following subsections contain draft material for a revised
1047610476
"`exists`" operation.
1047710477
</p>
1047810478
<p>
@@ -10487,7 +10487,10 @@ <h4>Syntax Restriction</h4>
1048710487
This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES`
1048810488
clause, and variables introduced by `AS` in `GROUP BY`.
1048910489
</blockquote>
10490-
<p>Extend the "in-scope" rules to include the variables in-scope from the current row:</p>
10490+
<p>
10491+
Extend the "in-scope" rules to include the possible
10492+
variables that are in-scope for the current row:
10493+
</p>
1049110494
<table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px">
1049210495
<tbody>
1049310496
<tr>
@@ -10501,10 +10504,15 @@ <h4>Syntax Restriction</h4>
1050110504
</tr>
1050210505
</tbody>
1050310506
</table>
10504-
<p class="note">
10505-
This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10506-
do not conflict with values assigned to variables within the pattern.
10507-
</p>
10507+
<div class="note">
10508+
<p>
10509+
This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10510+
do not conflict with values assigned to variables within the pattern.
10511+
</p>
10512+
<p>
10513+
This operation is performed as part of query parsing.
10514+
</p>
10515+
</div>
1050810516
</section>
1050910517
<section>
1051010518
<h4>Remapping</h4>
@@ -10529,7 +10537,7 @@ <h4>Remapping</h4>
1052910537
<pre>F(v) = v1 if v is in PV, where v1 is a fresh variable
1053010538
F(v) = v if v is not in PV</pre>
1053110539
<p>
10532-
Define the Projection Expression Variable Remapping `ProjectMap(P,PV)`
10540+
Define the Projection Expression Variable Remapping `ProjectMap(P, PV)`
1053310541
</p>
1053410542
<pre>ProjectMap(Project(A, PV)) = Project(A1, PV)
1053510543
where A1 is the result of applying F
@@ -10557,39 +10565,88 @@ <h4>Remapping</h4>
1055710565
Replacements may happen several times, depending on recursive order
1055810566
but each time a replacement is made, the variable not used anywhere else.
1055910567
</p>
10560-
10561-
<p class="note">
10562-
A variable inside a project expression that is not in the variables projected
10563-
is not affected by the values insertion operation because it is renamed apart.
10564-
</p>
10568+
10569+
<div class="note">
10570+
<p>
10571+
A variable inside a project expression that is not in the variables projected
10572+
is not affected by the values insertion operation because it is renamed apart.
10573+
</p>
10574+
<p>
10575+
This operation is as part of the <a href="#sparqlQuery">translation to the SPARQL
10576+
algebra</a>.
10577+
</p>
10578+
</div>
1056510579
</section>
1056610580
<section>
1056710581
<h4>Values Insertion</h4>
10582+
<p>
10583+
Alternative 1: rewrite the algebra during
10584+
<a href="#sparqlQuery">translation to the SPARQL algebra</a>
10585+
to include a function that evaluates to the current row.
10586+
</p>
10587+
1056810588
<div class="defn">
1056910589
<div>
10570-
<b>Definition: <span id="defn_valuesinsertion" name="defn_valuesinsertion">Values Insertion</span></b>
10590+
<b>Definition: <span id="defn_correlate" name="defn_correlate">Values In Scope</span></b>
1057110591
<p>
10572-
Define the Values Insertion function `ValuesInsert(X, μ)`
10592+
Define the function `BindingInScope()`.
10593+
Evaluation of `BindingInScope()` results in a table of one row,
10594+
being the current binding of the enclosing filter.
1057310595
</p>
10574-
<pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10596+
</div>
10597+
</div>
1057510598

10599+
<div class="defn">
10600+
<div>
10601+
<b>Definition: Access to the current binding</b>
10602+
<p>
10603+
During <a href="#sparqlQuery">translation to the SPARQL algebra</a>
10604+
</p>
10605+
<pre>
1057610606
Replace each occurence of `Y` in X where `Y` is one of
1057710607
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
1057810608
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
1057910609
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
1058010610
<a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10581-
with `join(Y, Table(μ))`.</pre>
10582-
10611+
with `join(Y, BindingInScope())`.</pre>
10612+
</div>
10613+
<div class="note">
10614+
c.f. section <a href="#sparqlTranslateGraphPatterns">Translate Graph Patterns</a>
10615+
where an empty basic graph pattern start any
10616+
<a href="#rGroupGraphPattern">GroupGraphPattern</a>.
10617+
It happens before the <a href="#sparqlSimplification">simplification step</a>.
1058310618
</div>
10584-
<p>@@ rename as ???correllate</p>
1058510619
</div>
1058610620

1058710621
<div class="example">
1058810622
<p>
1058910623
Examples
1059010624
</p>
1059110625
</div>
10626+
10627+
<p>
10628+
Alternative 2: rewrite the algebra during execution. This corresponds to the
10629+
<a href="https://github.com/w3c/sparql-dev/blob/main/SEP/SEP-0007/sep-0007.md">original SEP-0007 proposal</a>.
10630+
</p>
10631+
<div class="defn">
10632+
<div>
10633+
<b>Definition: <span id="defn_valuesinsertion" name="defn_valuesinsertion">Values Insertion</span></b>
10634+
<p>
10635+
Define the Values Insertion function `ValuesInsert(X, μ)`
10636+
</p>
10637+
<pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10638+
10639+
Replace each occurence of `Y` in X where `Y` is one of
10640+
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
10641+
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
10642+
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
10643+
<a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10644+
with `join(Y, Table(μ))`.</pre>
10645+
10646+
</div>
10647+
</div>
1059210648
</section>
10649+
1059310650
<section>
1059410651
<h4>Evaluation of EXISTS</h4>
1059510652
<div class="defn">
@@ -10599,7 +10656,7 @@ <h4>Evaluation of EXISTS</h4>
1059910656
define the Evaluation of Exists `exists(X)`
1060010657
</p>
1060110658
<pre>exists(X) = true
10602-
if eval( D(G), ValuesInsert(PrjMap(X), μ) )
10659+
if eval( D(G), ValuesInScope(PrjMap(X)), μ)
1060310660
is a non-empty solution sequence.
1060410661
exists(X) = false otherwise</pre>
1060510662
</div>

0 commit comments

Comments
 (0)