Skip to content

Commit 1ac39b7

Browse files
committed
Add 'row in scope' approach
1 parent b665b6c commit 1ac39b7

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
@@ -10643,7 +10643,7 @@ <h3>Evaluation Semantics</h3>
1064310643
<section>
1064410644
<h3>Values Insertion and `EXISTS`</h3>
1064510645
<div class="ednote">
10646-
<p>The following subsections contain draft of material for a revised
10646+
<p>The following subsections contain draft material for a revised
1064710647
"`exists`" operation.
1064810648
</p>
1064910649
<p>
@@ -10658,7 +10658,10 @@ <h4>Syntax Restriction</h4>
1065810658
This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES`
1065910659
clause, and variables introduced by `AS` in `GROUP BY`.
1066010660
</blockquote>
10661-
<p>Extend the "in-scope" rules to include the variables in-scope from the current row:</p>
10661+
<p>
10662+
Extend the "in-scope" rules to include the possible
10663+
variables that are in-scope for the current row:
10664+
</p>
1066210665
<table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px">
1066310666
<tbody>
1066410667
<tr>
@@ -10672,10 +10675,15 @@ <h4>Syntax Restriction</h4>
1067210675
</tr>
1067310676
</tbody>
1067410677
</table>
10675-
<p class="note">
10676-
This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10677-
do not conflict with values assigned to variables within the pattern.
10678-
</p>
10678+
<div class="note">
10679+
<p>
10680+
This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10681+
do not conflict with values assigned to variables within the pattern.
10682+
</p>
10683+
<p>
10684+
This operation is performed as part of query parsing.
10685+
</p>
10686+
</div>
1067910687
</section>
1068010688
<section>
1068110689
<h4>Remapping</h4>
@@ -10690,7 +10698,7 @@ <h4>Remapping</h4>
1069010698
the project expresssion.
1069110699
</p>
1069210700
<div class="defn">
10693-
<b>Definition: <span id="defn_projmap" name="defn_projmap">Projection Expression Variable Remapping</span></b>
10701+
<b>Definition: <span id="defn_projmap">Projection Expression Variable Remapping</span></b>
1069410702
<p>
1069510703
For a projection algebra operation #sparqlProjection `Project(A, PV)` acting on algreg express `A` and with set of variables `PV`, define
1069610704
a partial mapping `F` from
@@ -10700,7 +10708,7 @@ <h4>Remapping</h4>
1070010708
<pre>F(v) = v1 if v is in PV, where v1 is a fresh variable
1070110709
F(v) = v if v is not in PV</pre>
1070210710
<p>
10703-
Define the Projection Expression Variable Remapping `ProjectMap(P,PV)`
10711+
Define the Projection Expression Variable Remapping `ProjectMap(P, PV)`
1070410712
</p>
1070510713
<pre>ProjectMap(Project(A, PV)) = Project(A1, PV)
1070610714
where A1 is the result of applying F
@@ -10714,7 +10722,7 @@ <h4>Remapping</h4>
1071410722
</div>
1071510723
<p>This process is applied throughout the graph pattern of <code>EXISTS</code>:</p>
1071610724
<div class="defn">
10717-
<b>Definition: <span id="defn_varrename" name="defn_varrename">Variable Remapping</span></b>
10725+
<b>Definition: <span id="defn_varrename">Variable Remapping</span></b>
1071810726
<p>
1071910727
For any algebra expression `X`, define the Variable Remapping `PrjMap(X)`
1072010728
of algebra expression `X`:
@@ -10728,49 +10736,98 @@ <h4>Remapping</h4>
1072810736
Replacements may happen several times, depending on recursive order
1072910737
but each time a replacement is made, the variable not used anywhere else.
1073010738
</p>
10731-
10732-
<p class="note">
10733-
A variable inside a project expression that is not in the variables projected
10734-
is not affected by the values insertion operation because it is renamed apart.
10735-
</p>
10739+
10740+
<div class="note">
10741+
<p>
10742+
A variable inside a project expression that is not in the variables projected
10743+
is not affected by the values insertion operation because it is renamed apart.
10744+
</p>
10745+
<p>
10746+
This operation is as part of the <a href="#sparqlQuery">translation to the SPARQL
10747+
algebra</a>.
10748+
</p>
10749+
</div>
1073610750
</section>
1073710751
<section>
1073810752
<h4>Values Insertion</h4>
10753+
<p>
10754+
Alternative 1: rewrite the algebra during
10755+
<a href="#sparqlQuery">translation to the SPARQL algebra</a>
10756+
to include a function that evaluates to the current row.
10757+
</p>
10758+
1073910759
<div class="defn">
1074010760
<div>
10741-
<b>Definition: <span id="defn_valuesinsertion" name="defn_valuesinsertion">Values Insertion</span></b>
10761+
<b>Definition: <span id="defn_correlate">Values In Scope</span></b>
1074210762
<p>
10743-
Define the Values Insertion function `ValuesInsert(X, μ)`
10763+
Define the function `BindingInScope()`.
10764+
Evaluation of `BindingInScope()` results in a table of one row,
10765+
being the current binding of the enclosing filter.
1074410766
</p>
10745-
<pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10767+
</div>
10768+
</div>
1074610769

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

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

0 commit comments

Comments
 (0)