@@ -10622,7 +10622,7 @@ <h3>Evaluation Semantics</h3>
10622
10622
<section>
10623
10623
<h3>Values Insertion and `EXISTS`</h3>
10624
10624
<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
10626
10626
"`exists`" operation.
10627
10627
</p>
10628
10628
<p>
@@ -10637,7 +10637,10 @@ <h4>Syntax Restriction</h4>
10637
10637
This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES`
10638
10638
clause, and variables introduced by `AS` in `GROUP BY`.
10639
10639
</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>
10641
10644
<table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px">
10642
10645
<tbody>
10643
10646
<tr>
@@ -10651,10 +10654,15 @@ <h4>Syntax Restriction</h4>
10651
10654
</tr>
10652
10655
</tbody>
10653
10656
</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>
10658
10666
</section>
10659
10667
<section>
10660
10668
<h4>Remapping</h4>
@@ -10669,7 +10677,7 @@ <h4>Remapping</h4>
10669
10677
the project expresssion.
10670
10678
</p>
10671
10679
<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>
10673
10681
<p>
10674
10682
For a projection algebra operation #sparqlProjection `Project(A, PV)` acting on algreg express `A` and with set of variables `PV`, define
10675
10683
a partial mapping `F` from
@@ -10679,7 +10687,7 @@ <h4>Remapping</h4>
10679
10687
<pre>F(v) = v1 if v is in PV, where v1 is a fresh variable
10680
10688
F(v) = v if v is not in PV</pre>
10681
10689
<p>
10682
- Define the Projection Expression Variable Remapping `ProjectMap(P,PV)`
10690
+ Define the Projection Expression Variable Remapping `ProjectMap(P, PV)`
10683
10691
</p>
10684
10692
<pre>ProjectMap(Project(A, PV)) = Project(A1, PV)
10685
10693
where A1 is the result of applying F
@@ -10693,7 +10701,7 @@ <h4>Remapping</h4>
10693
10701
</div>
10694
10702
<p>This process is applied throughout the graph pattern of <code>EXISTS</code>:</p>
10695
10703
<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>
10697
10705
<p>
10698
10706
For any algebra expression `X`, define the Variable Remapping `PrjMap(X)`
10699
10707
of algebra expression `X`:
@@ -10707,49 +10715,98 @@ <h4>Remapping</h4>
10707
10715
Replacements may happen several times, depending on recursive order
10708
10716
but each time a replacement is made, the variable not used anywhere else.
10709
10717
</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>
10715
10729
</section>
10716
10730
<section>
10717
10731
<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
+
10718
10738
<div class="defn">
10719
10739
<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>
10721
10741
<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.
10723
10745
</p>
10724
- <pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10746
+ </div>
10747
+ </div>
10725
10748
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>
10726
10756
Replace each occurence of `Y` in X where `Y` is one of
10727
10757
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
10728
10758
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
10729
10759
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
10730
10760
<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>.
10733
10768
</div>
10734
- <p>@@ rename as ???correllate</p>
10735
10769
</div>
10736
10770
10737
10771
<div class="example">
10738
10772
<p>
10739
10773
Examples
10740
10774
</p>
10741
10775
</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>
10742
10798
</section>
10799
+
10743
10800
<section>
10744
10801
<h4>Evaluation of EXISTS</h4>
10745
10802
<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>
10747
10804
<p>
10748
10805
Let `μ` be the current solution mapping for a filter, and `X` a graph pattern,
10749
10806
define the Evaluation of Exists `exists(X)`
10750
10807
</p>
10751
10808
<pre>exists(X) = true
10752
- if eval( D(G), ValuesInsert (PrjMap(X), μ) )
10809
+ if eval( D(G), ValuesInScope (PrjMap(X)) , μ)
10753
10810
is a non-empty solution sequence.
10754
10811
exists(X) = false otherwise</pre>
10755
10812
</div>
0 commit comments