Skip to content

Commit bc4c6a0

Browse files
committed
Add 'row in scope' approach
1 parent f56cd27 commit bc4c6a0

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
@@ -10645,7 +10645,7 @@ <h3>Evaluation Semantics</h3>
1064510645
<section>
1064610646
<h3>Values Insertion and `EXISTS`</h3>
1064710647
<div class="ednote">
10648-
<p>The following subsections contain draft of material for a revised
10648+
<p>The following subsections contain draft material for a revised
1064910649
"`exists`" operation.
1065010650
</p>
1065110651
<p>
@@ -10660,7 +10660,10 @@ <h4>Syntax Restriction</h4>
1066010660
This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES`
1066110661
clause, and variables introduced by `AS` in `GROUP BY`.
1066210662
</blockquote>
10663-
<p>Extend the "in-scope" rules to include the variables in-scope from the current row:</p>
10663+
<p>
10664+
Extend the "in-scope" rules to include the possible
10665+
variables that are in-scope for the current row:
10666+
</p>
1066410667
<table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px">
1066510668
<tbody>
1066610669
<tr>
@@ -10674,10 +10677,15 @@ <h4>Syntax Restriction</h4>
1067410677
</tr>
1067510678
</tbody>
1067610679
</table>
10677-
<p class="note">
10678-
This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10679-
do not conflict with values assigned to variables within the pattern.
10680-
</p>
10680+
<div class="note">
10681+
<p>
10682+
This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10683+
do not conflict with values assigned to variables within the pattern.
10684+
</p>
10685+
<p>
10686+
This operation is performed as part of query parsing.
10687+
</p>
10688+
</div>
1068110689
</section>
1068210690
<section>
1068310691
<h4>Remapping</h4>
@@ -10692,7 +10700,7 @@ <h4>Remapping</h4>
1069210700
the project expresssion.
1069310701
</p>
1069410702
<div class="defn">
10695-
<b>Definition: <span id="defn_projmap" name="defn_projmap">Projection Expression Variable Remapping</span></b>
10703+
<b>Definition: <span id="defn_projmap">Projection Expression Variable Remapping</span></b>
1069610704
<p>
1069710705
For a projection algebra operation #sparqlProjection `Project(A, PV)` acting on algreg express `A` and with set of variables `PV`, define
1069810706
a partial mapping `F` from
@@ -10702,7 +10710,7 @@ <h4>Remapping</h4>
1070210710
<pre>F(v) = v1 if v is in PV, where v1 is a fresh variable
1070310711
F(v) = v if v is not in PV</pre>
1070410712
<p>
10705-
Define the Projection Expression Variable Remapping `ProjectMap(P,PV)`
10713+
Define the Projection Expression Variable Remapping `ProjectMap(P, PV)`
1070610714
</p>
1070710715
<pre>ProjectMap(Project(A, PV)) = Project(A1, PV)
1070810716
where A1 is the result of applying F
@@ -10716,7 +10724,7 @@ <h4>Remapping</h4>
1071610724
</div>
1071710725
<p>This process is applied throughout the graph pattern of <code>EXISTS</code>:</p>
1071810726
<div class="defn">
10719-
<b>Definition: <span id="defn_varrename" name="defn_varrename">Variable Remapping</span></b>
10727+
<b>Definition: <span id="defn_varrename">Variable Remapping</span></b>
1072010728
<p>
1072110729
For any algebra expression `X`, define the Variable Remapping `PrjMap(X)`
1072210730
of algebra expression `X`:
@@ -10730,49 +10738,98 @@ <h4>Remapping</h4>
1073010738
Replacements may happen several times, depending on recursive order
1073110739
but each time a replacement is made, the variable not used anywhere else.
1073210740
</p>
10733-
10734-
<p class="note">
10735-
A variable inside a project expression that is not in the variables projected
10736-
is not affected by the values insertion operation because it is renamed apart.
10737-
</p>
10741+
10742+
<div class="note">
10743+
<p>
10744+
A variable inside a project expression that is not in the variables projected
10745+
is not affected by the values insertion operation because it is renamed apart.
10746+
</p>
10747+
<p>
10748+
This operation is as part of the <a href="#sparqlQuery">translation to the SPARQL
10749+
algebra</a>.
10750+
</p>
10751+
</div>
1073810752
</section>
1073910753
<section>
1074010754
<h4>Values Insertion</h4>
10755+
<p>
10756+
Alternative 1: rewrite the algebra during
10757+
<a href="#sparqlQuery">translation to the SPARQL algebra</a>
10758+
to include a function that evaluates to the current row.
10759+
</p>
10760+
1074110761
<div class="defn">
1074210762
<div>
10743-
<b>Definition: <span id="defn_valuesinsertion" name="defn_valuesinsertion">Values Insertion</span></b>
10763+
<b>Definition: <span id="defn_correlate">Values In Scope</span></b>
1074410764
<p>
10745-
Define the Values Insertion function `ValuesInsert(X, μ)`
10765+
Define the function `BindingInScope()`.
10766+
Evaluation of `BindingInScope()` results in a table of one row,
10767+
being the current binding of the enclosing filter.
1074610768
</p>
10747-
<pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10769+
</div>
10770+
</div>
1074810771

10772+
<div class="defn">
10773+
<div>
10774+
<b>Definition: Access to the current binding</b>
10775+
<p>
10776+
During <a href="#sparqlQuery">translation to the SPARQL algebra</a>
10777+
</p>
10778+
<pre>
1074910779
Replace each occurence of `Y` in X where `Y` is one of
1075010780
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
1075110781
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
1075210782
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
1075310783
<a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10754-
with `join(Y, Table(μ))`.</pre>
10755-
10784+
with `join(Y, BindingInScope())`.</pre>
10785+
</div>
10786+
<div class="note">
10787+
c.f. section <a href="#sparqlTranslateGraphPatterns">Translate Graph Patterns</a>
10788+
where an empty basic graph pattern start any
10789+
<a href="#rGroupGraphPattern">GroupGraphPattern</a>.
10790+
It happens before the <a href="#sparqlSimplification">simplification step</a>.
1075610791
</div>
10757-
<p>@@ rename as ???correllate</p>
1075810792
</div>
1075910793

1076010794
<div class="example">
1076110795
<p>
1076210796
Examples
1076310797
</p>
1076410798
</div>
10799+
10800+
<p>
10801+
Alternative 2: rewrite the algebra during execution. This corresponds to the
10802+
<a href="https://github.com/w3c/sparql-dev/blob/main/SEP/SEP-0007/sep-0007.md">original SEP-0007 proposal</a>.
10803+
</p>
10804+
<div class="defn">
10805+
<div>
10806+
<b>Definition: <span id="defn_valuesinsertion">Values Insertion</span></b>
10807+
<p>
10808+
Define the Values Insertion function `ValuesInsert(X, μ)`
10809+
</p>
10810+
<pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10811+
10812+
Replace each occurence of `Y` in X where `Y` is one of
10813+
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
10814+
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
10815+
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
10816+
<a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10817+
with `join(Y, Table(μ))`.</pre>
10818+
10819+
</div>
10820+
</div>
1076510821
</section>
10822+
1076610823
<section>
1076710824
<h4>Evaluation of EXISTS</h4>
1076810825
<div class="defn">
10769-
<b>Definition: <span id="x-defn_evalExists" name="x-defn_evalExists">Evaluation of Exists</span></b>
10826+
<b>Definition: <span id="x-defn_evalExists">Evaluation of Exists</span></b>
1077010827
<p>
1077110828
Let `μ` be the current solution mapping for a filter, and `X` a graph pattern,
1077210829
define the Evaluation of Exists `exists(X)`
1077310830
</p>
1077410831
<pre>exists(X) = true
10775-
if eval( D(G), ValuesInsert(PrjMap(X), μ) )
10832+
if eval( D(G), ValuesInScope(PrjMap(X)), μ)
1077610833
is a non-empty solution sequence.
1077710834
exists(X) = false otherwise</pre>
1077810835
</div>

0 commit comments

Comments
 (0)