@@ -10597,7 +10597,7 @@ <h3>Evaluation Semantics</h3>
10597
10597
<section>
10598
10598
<h3>Values Insertion and `EXISTS`</h3>
10599
10599
<div class="ednote">
10600
- <p>The following subsections contain draft of material for a revised
10600
+ <p>The following subsections contain draft material for a revised
10601
10601
"`exists`" operation.
10602
10602
</p>
10603
10603
<p>
@@ -10612,7 +10612,10 @@ <h4>Syntax Restriction</h4>
10612
10612
This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES`
10613
10613
clause, and variables introduced by `AS` in `GROUP BY`.
10614
10614
</blockquote>
10615
- <p>Extend the "in-scope" rules to include the variables in-scope from the current row:</p>
10615
+ <p>
10616
+ Extend the "in-scope" rules to include the possible
10617
+ variables that are in-scope for the current row:
10618
+ </p>
10616
10619
<table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px">
10617
10620
<tbody>
10618
10621
<tr>
@@ -10626,10 +10629,15 @@ <h4>Syntax Restriction</h4>
10626
10629
</tr>
10627
10630
</tbody>
10628
10631
</table>
10629
- <p class="note">
10630
- This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10631
- do not conflict with values assigned to variables within the pattern.
10632
- </p>
10632
+ <div class="note">
10633
+ <p>
10634
+ This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10635
+ do not conflict with values assigned to variables within the pattern.
10636
+ </p>
10637
+ <p>
10638
+ This operation is performed as part of query parsing.
10639
+ </p>
10640
+ </div>
10633
10641
</section>
10634
10642
<section>
10635
10643
<h4>Remapping</h4>
@@ -10644,7 +10652,7 @@ <h4>Remapping</h4>
10644
10652
the project expresssion.
10645
10653
</p>
10646
10654
<div class="defn">
10647
- <b>Definition: <span id="defn_projmap" name="defn_projmap" >Projection Expression Variable Remapping</span></b>
10655
+ <b>Definition: <span id="defn_projmap">Projection Expression Variable Remapping</span></b>
10648
10656
<p>
10649
10657
For a projection algebra operation #sparqlProjection `Project(A, PV)` acting on algreg express `A` and with set of variables `PV`, define
10650
10658
a partial mapping `F` from
@@ -10654,7 +10662,7 @@ <h4>Remapping</h4>
10654
10662
<pre>F(v) = v1 if v is in PV, where v1 is a fresh variable
10655
10663
F(v) = v if v is not in PV</pre>
10656
10664
<p>
10657
- Define the Projection Expression Variable Remapping `ProjectMap(P,PV)`
10665
+ Define the Projection Expression Variable Remapping `ProjectMap(P, PV)`
10658
10666
</p>
10659
10667
<pre>ProjectMap(Project(A, PV)) = Project(A1, PV)
10660
10668
where A1 is the result of applying F
@@ -10668,7 +10676,7 @@ <h4>Remapping</h4>
10668
10676
</div>
10669
10677
<p>This process is applied throughout the graph pattern of <code>EXISTS</code>:</p>
10670
10678
<div class="defn">
10671
- <b>Definition: <span id="defn_varrename" name="defn_varrename" >Variable Remapping</span></b>
10679
+ <b>Definition: <span id="defn_varrename">Variable Remapping</span></b>
10672
10680
<p>
10673
10681
For any algebra expression `X`, define the Variable Remapping `PrjMap(X)`
10674
10682
of algebra expression `X`:
@@ -10682,49 +10690,98 @@ <h4>Remapping</h4>
10682
10690
Replacements may happen several times, depending on recursive order
10683
10691
but each time a replacement is made, the variable not used anywhere else.
10684
10692
</p>
10685
-
10686
- <p class="note">
10687
- A variable inside a project expression that is not in the variables projected
10688
- is not affected by the values insertion operation because it is renamed apart.
10689
- </p>
10693
+
10694
+ <div class="note">
10695
+ <p>
10696
+ A variable inside a project expression that is not in the variables projected
10697
+ is not affected by the values insertion operation because it is renamed apart.
10698
+ </p>
10699
+ <p>
10700
+ This operation is as part of the <a href="#sparqlQuery">translation to the SPARQL
10701
+ algebra</a>.
10702
+ </p>
10703
+ </div>
10690
10704
</section>
10691
10705
<section>
10692
10706
<h4>Values Insertion</h4>
10707
+ <p>
10708
+ Alternative 1: rewrite the algebra during
10709
+ <a href="#sparqlQuery">translation to the SPARQL algebra</a>
10710
+ to include a function that evaluates to the current row.
10711
+ </p>
10712
+
10693
10713
<div class="defn">
10694
10714
<div>
10695
- <b>Definition: <span id="defn_valuesinsertion" name="defn_valuesinsertion" >Values Insertion </span></b>
10715
+ <b>Definition: <span id="defn_correlate" >Values In Scope </span></b>
10696
10716
<p>
10697
- Define the Values Insertion function `ValuesInsert(X, μ)`
10717
+ Define the function `BindingInScope()`.
10718
+ Evaluation of `BindingInScope()` results in a table of one row,
10719
+ being the current binding of the enclosing filter.
10698
10720
</p>
10699
- <pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10721
+ </div>
10722
+ </div>
10700
10723
10724
+ <div class="defn">
10725
+ <div>
10726
+ <b>Definition: Access to the current binding</b>
10727
+ <p>
10728
+ During <a href="#sparqlQuery">translation to the SPARQL algebra</a>
10729
+ </p>
10730
+ <pre>
10701
10731
Replace each occurence of `Y` in X where `Y` is one of
10702
10732
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
10703
10733
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
10704
10734
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
10705
10735
<a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10706
- with `join(Y, Table(μ))`.</pre>
10707
-
10736
+ with `join(Y, BindingInScope())`.</pre>
10737
+ </div>
10738
+ <div class="note">
10739
+ c.f. section <a href="#sparqlTranslateGraphPatterns">Translate Graph Patterns</a>
10740
+ where an empty basic graph pattern start any
10741
+ <a href="#rGroupGraphPattern">GroupGraphPattern</a>.
10742
+ It happens before the <a href="#sparqlSimplification">simplification step</a>.
10708
10743
</div>
10709
- <p>@@ rename as ???correllate</p>
10710
10744
</div>
10711
10745
10712
10746
<div class="example">
10713
10747
<p>
10714
10748
Examples
10715
10749
</p>
10716
10750
</div>
10751
+
10752
+ <p>
10753
+ Alternative 2: rewrite the algebra during execution. This corresponds to the
10754
+ <a href="https://github.com/w3c/sparql-dev/blob/main/SEP/SEP-0007/sep-0007.md">original SEP-0007 proposal</a>.
10755
+ </p>
10756
+ <div class="defn">
10757
+ <div>
10758
+ <b>Definition: <span id="defn_valuesinsertion">Values Insertion</span></b>
10759
+ <p>
10760
+ Define the Values Insertion function `ValuesInsert(X, μ)`
10761
+ </p>
10762
+ <pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10763
+
10764
+ Replace each occurence of `Y` in X where `Y` is one of
10765
+ <a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
10766
+ <a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
10767
+ <a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
10768
+ <a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10769
+ with `join(Y, Table(μ))`.</pre>
10770
+
10771
+ </div>
10772
+ </div>
10717
10773
</section>
10774
+
10718
10775
<section>
10719
10776
<h4>Evaluation of EXISTS</h4>
10720
10777
<div class="defn">
10721
- <b>Definition: <span id="x-defn_evalExists" name="x-defn_evalExists" >Evaluation of Exists</span></b>
10778
+ <b>Definition: <span id="x-defn_evalExists">Evaluation of Exists</span></b>
10722
10779
<p>
10723
10780
Let `μ` be the current solution mapping for a filter, and `X` a graph pattern,
10724
10781
define the Evaluation of Exists `exists(X)`
10725
10782
</p>
10726
10783
<pre>exists(X) = true
10727
- if eval( D(G), ValuesInsert (PrjMap(X), μ) )
10784
+ if eval( D(G), ValuesInScope (PrjMap(X)) , μ)
10728
10785
is a non-empty solution sequence.
10729
10786
exists(X) = false otherwise</pre>
10730
10787
</div>
0 commit comments