Skip to content

Commit 4730d14

Browse files
committed
Add 'row in scope' approach
1 parent 2c1e0a7 commit 4730d14

File tree

1 file changed

+79
-22
lines changed

1 file changed

+79
-22
lines changed

spec/index.html

Lines changed: 79 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10597,7 +10597,7 @@ <h3>Evaluation Semantics</h3>
1059710597
<section>
1059810598
<h3>Values Insertion and `EXISTS`</h3>
1059910599
<div class="ednote">
10600-
<p>The following subsections contain draft of material for a revised
10600+
<p>The following subsections contain draft material for a revised
1060110601
"`exists`" operation.
1060210602
</p>
1060310603
<p>
@@ -10612,7 +10612,10 @@ <h4>Syntax Restriction</h4>
1061210612
This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES`
1061310613
clause, and variables introduced by `AS` in `GROUP BY`.
1061410614
</blockquote>
10615-
<p>Extend the "in-scope" rules to include the variables in-scope from the current row:</p>
10615+
<p>
10616+
Extend the "in-scope" rules to include the possible
10617+
variables that are in-scope for the current row:
10618+
</p>
1061610619
<table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px">
1061710620
<tbody>
1061810621
<tr>
@@ -10626,10 +10629,15 @@ <h4>Syntax Restriction</h4>
1062610629
</tr>
1062710630
</tbody>
1062810631
</table>
10629-
<p class="note">
10630-
This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10631-
do not conflict with values assigned to variables within the pattern.
10632-
</p>
10632+
<div class="note">
10633+
<p>
10634+
This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10635+
do not conflict with values assigned to variables within the pattern.
10636+
</p>
10637+
<p>
10638+
This operation is performed as part of query parsing.
10639+
</p>
10640+
</div>
1063310641
</section>
1063410642
<section>
1063510643
<h4>Remapping</h4>
@@ -10644,7 +10652,7 @@ <h4>Remapping</h4>
1064410652
the project expresssion.
1064510653
</p>
1064610654
<div class="defn">
10647-
<b>Definition: <span id="defn_projmap" name="defn_projmap">Projection Expression Variable Remapping</span></b>
10655+
<b>Definition: <span id="defn_projmap">Projection Expression Variable Remapping</span></b>
1064810656
<p>
1064910657
For a projection algebra operation #sparqlProjection `Project(A, PV)` acting on algreg express `A` and with set of variables `PV`, define
1065010658
a partial mapping `F` from
@@ -10654,7 +10662,7 @@ <h4>Remapping</h4>
1065410662
<pre>F(v) = v1 if v is in PV, where v1 is a fresh variable
1065510663
F(v) = v if v is not in PV</pre>
1065610664
<p>
10657-
Define the Projection Expression Variable Remapping `ProjectMap(P,PV)`
10665+
Define the Projection Expression Variable Remapping `ProjectMap(P, PV)`
1065810666
</p>
1065910667
<pre>ProjectMap(Project(A, PV)) = Project(A1, PV)
1066010668
where A1 is the result of applying F
@@ -10668,7 +10676,7 @@ <h4>Remapping</h4>
1066810676
</div>
1066910677
<p>This process is applied throughout the graph pattern of <code>EXISTS</code>:</p>
1067010678
<div class="defn">
10671-
<b>Definition: <span id="defn_varrename" name="defn_varrename">Variable Remapping</span></b>
10679+
<b>Definition: <span id="defn_varrename">Variable Remapping</span></b>
1067210680
<p>
1067310681
For any algebra expression `X`, define the Variable Remapping `PrjMap(X)`
1067410682
of algebra expression `X`:
@@ -10682,49 +10690,98 @@ <h4>Remapping</h4>
1068210690
Replacements may happen several times, depending on recursive order
1068310691
but each time a replacement is made, the variable not used anywhere else.
1068410692
</p>
10685-
10686-
<p class="note">
10687-
A variable inside a project expression that is not in the variables projected
10688-
is not affected by the values insertion operation because it is renamed apart.
10689-
</p>
10693+
10694+
<div class="note">
10695+
<p>
10696+
A variable inside a project expression that is not in the variables projected
10697+
is not affected by the values insertion operation because it is renamed apart.
10698+
</p>
10699+
<p>
10700+
This operation is as part of the <a href="#sparqlQuery">translation to the SPARQL
10701+
algebra</a>.
10702+
</p>
10703+
</div>
1069010704
</section>
1069110705
<section>
1069210706
<h4>Values Insertion</h4>
10707+
<p>
10708+
Alternative 1: rewrite the algebra during
10709+
<a href="#sparqlQuery">translation to the SPARQL algebra</a>
10710+
to include a function that evaluates to the current row.
10711+
</p>
10712+
1069310713
<div class="defn">
1069410714
<div>
10695-
<b>Definition: <span id="defn_valuesinsertion" name="defn_valuesinsertion">Values Insertion</span></b>
10715+
<b>Definition: <span id="defn_correlate">Values In Scope</span></b>
1069610716
<p>
10697-
Define the Values Insertion function `ValuesInsert(X, μ)`
10717+
Define the function `BindingInScope()`.
10718+
Evaluation of `BindingInScope()` results in a table of one row,
10719+
being the current binding of the enclosing filter.
1069810720
</p>
10699-
<pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10721+
</div>
10722+
</div>
1070010723

10724+
<div class="defn">
10725+
<div>
10726+
<b>Definition: Access to the current binding</b>
10727+
<p>
10728+
During <a href="#sparqlQuery">translation to the SPARQL algebra</a>
10729+
</p>
10730+
<pre>
1070110731
Replace each occurence of `Y` in X where `Y` is one of
1070210732
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
1070310733
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
1070410734
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
1070510735
<a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10706-
with `join(Y, Table(μ))`.</pre>
10707-
10736+
with `join(Y, BindingInScope())`.</pre>
10737+
</div>
10738+
<div class="note">
10739+
c.f. section <a href="#sparqlTranslateGraphPatterns">Translate Graph Patterns</a>
10740+
where an empty basic graph pattern start any
10741+
<a href="#rGroupGraphPattern">GroupGraphPattern</a>.
10742+
It happens before the <a href="#sparqlSimplification">simplification step</a>.
1070810743
</div>
10709-
<p>@@ rename as ???correllate</p>
1071010744
</div>
1071110745

1071210746
<div class="example">
1071310747
<p>
1071410748
Examples
1071510749
</p>
1071610750
</div>
10751+
10752+
<p>
10753+
Alternative 2: rewrite the algebra during execution. This corresponds to the
10754+
<a href="https://github.com/w3c/sparql-dev/blob/main/SEP/SEP-0007/sep-0007.md">original SEP-0007 proposal</a>.
10755+
</p>
10756+
<div class="defn">
10757+
<div>
10758+
<b>Definition: <span id="defn_valuesinsertion">Values Insertion</span></b>
10759+
<p>
10760+
Define the Values Insertion function `ValuesInsert(X, μ)`
10761+
</p>
10762+
<pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10763+
10764+
Replace each occurence of `Y` in X where `Y` is one of
10765+
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
10766+
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
10767+
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
10768+
<a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10769+
with `join(Y, Table(μ))`.</pre>
10770+
10771+
</div>
10772+
</div>
1071710773
</section>
10774+
1071810775
<section>
1071910776
<h4>Evaluation of EXISTS</h4>
1072010777
<div class="defn">
10721-
<b>Definition: <span id="x-defn_evalExists" name="x-defn_evalExists">Evaluation of Exists</span></b>
10778+
<b>Definition: <span id="x-defn_evalExists">Evaluation of Exists</span></b>
1072210779
<p>
1072310780
Let `μ` be the current solution mapping for a filter, and `X` a graph pattern,
1072410781
define the Evaluation of Exists `exists(X)`
1072510782
</p>
1072610783
<pre>exists(X) = true
10727-
if eval( D(G), ValuesInsert(PrjMap(X), μ) )
10784+
if eval( D(G), ValuesInScope(PrjMap(X)), μ)
1072810785
is a non-empty solution sequence.
1072910786
exists(X) = false otherwise</pre>
1073010787
</div>

0 commit comments

Comments
 (0)