Skip to content

Commit eed6f4f

Browse files
committed
Add 'row in scope' approach
1 parent f409261 commit eed6f4f

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
@@ -10622,7 +10622,7 @@ <h3>Evaluation Semantics</h3>
1062210622
<section>
1062310623
<h3>Values Insertion and `EXISTS`</h3>
1062410624
<div class="ednote">
10625-
<p>The following subsections contain draft of material for a revised
10625+
<p>The following subsections contain draft material for a revised
1062610626
"`exists`" operation.
1062710627
</p>
1062810628
<p>
@@ -10637,7 +10637,10 @@ <h4>Syntax Restriction</h4>
1063710637
This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES`
1063810638
clause, and variables introduced by `AS` in `GROUP BY`.
1063910639
</blockquote>
10640-
<p>Extend the "in-scope" rules to include the variables in-scope from the current row:</p>
10640+
<p>
10641+
Extend the "in-scope" rules to include the possible
10642+
variables that are in-scope for the current row:
10643+
</p>
1064110644
<table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px">
1064210645
<tbody>
1064310646
<tr>
@@ -10651,10 +10654,15 @@ <h4>Syntax Restriction</h4>
1065110654
</tr>
1065210655
</tbody>
1065310656
</table>
10654-
<p class="note">
10655-
This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10656-
do not conflict with values assigned to variables within the pattern.
10657-
</p>
10657+
<div class="note">
10658+
<p>
10659+
This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10660+
do not conflict with values assigned to variables within the pattern.
10661+
</p>
10662+
<p>
10663+
This operation is performed as part of query parsing.
10664+
</p>
10665+
</div>
1065810666
</section>
1065910667
<section>
1066010668
<h4>Remapping</h4>
@@ -10669,7 +10677,7 @@ <h4>Remapping</h4>
1066910677
the project expresssion.
1067010678
</p>
1067110679
<div class="defn">
10672-
<b>Definition: <span id="defn_projmap" name="defn_projmap">Projection Expression Variable Remapping</span></b>
10680+
<b>Definition: <span id="defn_projmap">Projection Expression Variable Remapping</span></b>
1067310681
<p>
1067410682
For a projection algebra operation #sparqlProjection `Project(A, PV)` acting on algreg express `A` and with set of variables `PV`, define
1067510683
a partial mapping `F` from
@@ -10679,7 +10687,7 @@ <h4>Remapping</h4>
1067910687
<pre>F(v) = v1 if v is in PV, where v1 is a fresh variable
1068010688
F(v) = v if v is not in PV</pre>
1068110689
<p>
10682-
Define the Projection Expression Variable Remapping `ProjectMap(P,PV)`
10690+
Define the Projection Expression Variable Remapping `ProjectMap(P, PV)`
1068310691
</p>
1068410692
<pre>ProjectMap(Project(A, PV)) = Project(A1, PV)
1068510693
where A1 is the result of applying F
@@ -10693,7 +10701,7 @@ <h4>Remapping</h4>
1069310701
</div>
1069410702
<p>This process is applied throughout the graph pattern of <code>EXISTS</code>:</p>
1069510703
<div class="defn">
10696-
<b>Definition: <span id="defn_varrename" name="defn_varrename">Variable Remapping</span></b>
10704+
<b>Definition: <span id="defn_varrename">Variable Remapping</span></b>
1069710705
<p>
1069810706
For any algebra expression `X`, define the Variable Remapping `PrjMap(X)`
1069910707
of algebra expression `X`:
@@ -10707,49 +10715,98 @@ <h4>Remapping</h4>
1070710715
Replacements may happen several times, depending on recursive order
1070810716
but each time a replacement is made, the variable not used anywhere else.
1070910717
</p>
10710-
10711-
<p class="note">
10712-
A variable inside a project expression that is not in the variables projected
10713-
is not affected by the values insertion operation because it is renamed apart.
10714-
</p>
10718+
10719+
<div class="note">
10720+
<p>
10721+
A variable inside a project expression that is not in the variables projected
10722+
is not affected by the values insertion operation because it is renamed apart.
10723+
</p>
10724+
<p>
10725+
This operation is as part of the <a href="#sparqlQuery">translation to the SPARQL
10726+
algebra</a>.
10727+
</p>
10728+
</div>
1071510729
</section>
1071610730
<section>
1071710731
<h4>Values Insertion</h4>
10732+
<p>
10733+
Alternative 1: rewrite the algebra during
10734+
<a href="#sparqlQuery">translation to the SPARQL algebra</a>
10735+
to include a function that evaluates to the current row.
10736+
</p>
10737+
1071810738
<div class="defn">
1071910739
<div>
10720-
<b>Definition: <span id="defn_valuesinsertion" name="defn_valuesinsertion">Values Insertion</span></b>
10740+
<b>Definition: <span id="defn_correlate">Values In Scope</span></b>
1072110741
<p>
10722-
Define the Values Insertion function `ValuesInsert(X, μ)`
10742+
Define the function `BindingInScope()`.
10743+
Evaluation of `BindingInScope()` results in a table of one row,
10744+
being the current binding of the enclosing filter.
1072310745
</p>
10724-
<pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10746+
</div>
10747+
</div>
1072510748

10749+
<div class="defn">
10750+
<div>
10751+
<b>Definition: Access to the current binding</b>
10752+
<p>
10753+
During <a href="#sparqlQuery">translation to the SPARQL algebra</a>
10754+
</p>
10755+
<pre>
1072610756
Replace each occurence of `Y` in X where `Y` is one of
1072710757
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
1072810758
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
1072910759
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
1073010760
<a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10731-
with `join(Y, Table(μ))`.</pre>
10732-
10761+
with `join(Y, BindingInScope())`.</pre>
10762+
</div>
10763+
<div class="note">
10764+
c.f. section <a href="#sparqlTranslateGraphPatterns">Translate Graph Patterns</a>
10765+
where an empty basic graph pattern start any
10766+
<a href="#rGroupGraphPattern">GroupGraphPattern</a>.
10767+
It happens before the <a href="#sparqlSimplification">simplification step</a>.
1073310768
</div>
10734-
<p>@@ rename as ???correllate</p>
1073510769
</div>
1073610770

1073710771
<div class="example">
1073810772
<p>
1073910773
Examples
1074010774
</p>
1074110775
</div>
10776+
10777+
<p>
10778+
Alternative 2: rewrite the algebra during execution. This corresponds to the
10779+
<a href="https://github.com/w3c/sparql-dev/blob/main/SEP/SEP-0007/sep-0007.md">original SEP-0007 proposal</a>.
10780+
</p>
10781+
<div class="defn">
10782+
<div>
10783+
<b>Definition: <span id="defn_valuesinsertion">Values Insertion</span></b>
10784+
<p>
10785+
Define the Values Insertion function `ValuesInsert(X, μ)`
10786+
</p>
10787+
<pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10788+
10789+
Replace each occurence of `Y` in X where `Y` is one of
10790+
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
10791+
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
10792+
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
10793+
<a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10794+
with `join(Y, Table(μ))`.</pre>
10795+
10796+
</div>
10797+
</div>
1074210798
</section>
10799+
1074310800
<section>
1074410801
<h4>Evaluation of EXISTS</h4>
1074510802
<div class="defn">
10746-
<b>Definition: <span id="x-defn_evalExists" name="x-defn_evalExists">Evaluation of Exists</span></b>
10803+
<b>Definition: <span id="x-defn_evalExists">Evaluation of Exists</span></b>
1074710804
<p>
1074810805
Let `μ` be the current solution mapping for a filter, and `X` a graph pattern,
1074910806
define the Evaluation of Exists `exists(X)`
1075010807
</p>
1075110808
<pre>exists(X) = true
10752-
if eval( D(G), ValuesInsert(PrjMap(X), μ) )
10809+
if eval( D(G), ValuesInScope(PrjMap(X)), μ)
1075310810
is a non-empty solution sequence.
1075410811
exists(X) = false otherwise</pre>
1075510812
</div>

0 commit comments

Comments
 (0)