@@ -10643,7 +10643,7 @@ <h3>Evaluation Semantics</h3>
10643
10643
<section>
10644
10644
<h3>Values Insertion and `EXISTS`</h3>
10645
10645
<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
10647
10647
"`exists`" operation.
10648
10648
</p>
10649
10649
<p>
@@ -10658,7 +10658,10 @@ <h4>Syntax Restriction</h4>
10658
10658
This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES`
10659
10659
clause, and variables introduced by `AS` in `GROUP BY`.
10660
10660
</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>
10662
10665
<table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px">
10663
10666
<tbody>
10664
10667
<tr>
@@ -10672,10 +10675,15 @@ <h4>Syntax Restriction</h4>
10672
10675
</tr>
10673
10676
</tbody>
10674
10677
</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>
10679
10687
</section>
10680
10688
<section>
10681
10689
<h4>Remapping</h4>
@@ -10690,7 +10698,7 @@ <h4>Remapping</h4>
10690
10698
the project expresssion.
10691
10699
</p>
10692
10700
<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>
10694
10702
<p>
10695
10703
For a projection algebra operation #sparqlProjection `Project(A, PV)` acting on algreg express `A` and with set of variables `PV`, define
10696
10704
a partial mapping `F` from
@@ -10700,7 +10708,7 @@ <h4>Remapping</h4>
10700
10708
<pre>F(v) = v1 if v is in PV, where v1 is a fresh variable
10701
10709
F(v) = v if v is not in PV</pre>
10702
10710
<p>
10703
- Define the Projection Expression Variable Remapping `ProjectMap(P,PV)`
10711
+ Define the Projection Expression Variable Remapping `ProjectMap(P, PV)`
10704
10712
</p>
10705
10713
<pre>ProjectMap(Project(A, PV)) = Project(A1, PV)
10706
10714
where A1 is the result of applying F
@@ -10714,7 +10722,7 @@ <h4>Remapping</h4>
10714
10722
</div>
10715
10723
<p>This process is applied throughout the graph pattern of <code>EXISTS</code>:</p>
10716
10724
<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>
10718
10726
<p>
10719
10727
For any algebra expression `X`, define the Variable Remapping `PrjMap(X)`
10720
10728
of algebra expression `X`:
@@ -10728,49 +10736,98 @@ <h4>Remapping</h4>
10728
10736
Replacements may happen several times, depending on recursive order
10729
10737
but each time a replacement is made, the variable not used anywhere else.
10730
10738
</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>
10736
10750
</section>
10737
10751
<section>
10738
10752
<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
+
10739
10759
<div class="defn">
10740
10760
<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>
10742
10762
<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.
10744
10766
</p>
10745
- <pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10767
+ </div>
10768
+ </div>
10746
10769
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>
10747
10777
Replace each occurence of `Y` in X where `Y` is one of
10748
10778
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
10749
10779
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
10750
10780
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
10751
10781
<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>.
10754
10789
</div>
10755
- <p>@@ rename as ???correllate</p>
10756
10790
</div>
10757
10791
10758
10792
<div class="example">
10759
10793
<p>
10760
10794
Examples
10761
10795
</p>
10762
10796
</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>
10763
10819
</section>
10820
+
10764
10821
<section>
10765
10822
<h4>Evaluation of EXISTS</h4>
10766
10823
<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>
10768
10825
<p>
10769
10826
Let `μ` be the current solution mapping for a filter, and `X` a graph pattern,
10770
10827
define the Evaluation of Exists `exists(X)`
10771
10828
</p>
10772
10829
<pre>exists(X) = true
10773
- if eval( D(G), ValuesInsert (PrjMap(X), μ) )
10830
+ if eval( D(G), ValuesInScope (PrjMap(X)) , μ)
10774
10831
is a non-empty solution sequence.
10775
10832
exists(X) = false otherwise</pre>
10776
10833
</div>
0 commit comments