-
Notifications
You must be signed in to change notification settings - Fork 2
Definitions for Values Insertion #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -10424,7 +10424,205 @@ <h3>Evaluation Semantics</h3> | |||||
<a href="#defn_eval" class="evalFct">eval</a>( |D|(|G|), Slice(|L|, |start|, |length|) ) = <a href="#defn_algSlice" class="algFct">Slice</a>( <a href="#defn_eval" class="evalFct">eval</a>(|D|(|G|), |L|), |start|, |length| ) | ||||||
</p> | ||||||
</div> | ||||||
|
||||||
<!-- ValuesInsertion --> | ||||||
<section> | ||||||
<h3>Values Insertion and `EXISTS`</h3> | ||||||
<div class="ednote"> | ||||||
<p>The following subsections contain draft material for a revised | ||||||
"`exists`" operation. | ||||||
</p> | ||||||
<p> | ||||||
Background: <a href="https://github.com/w3c/sparql-dev/blob/main/SEP/SEP-0007/sep-0007.md">SPARQL CG SEP-0007</a> | ||||||
</p> | ||||||
</div> | ||||||
<section> | ||||||
<h4>Syntax Restriction</h4> | ||||||
<p><i>Additional [[[#sparqlGrammar]]] note:</i></p> | ||||||
<blockquote> | ||||||
Any variable that is assigned to in the graph pattern of `EXISTS`/`NOT EXISTS` must not be in-scope. | ||||||
This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES` | ||||||
clause, and variables introduced by `AS` in `GROUP BY`. | ||||||
</blockquote> | ||||||
<p> | ||||||
Extend the "in-scope" rules to include the possible | ||||||
variables that are in-scope for the current row: | ||||||
</p> | ||||||
<table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px"> | ||||||
<tbody> | ||||||
<tr> | ||||||
<th>Syntax Form</th> | ||||||
<th>In-scope variables</th> | ||||||
</tr> | ||||||
<tr> | ||||||
<td>`EXISTS` and `NOT EXISTS` filters </td> | ||||||
<td><code>v</code> is in-scope if it is in-scope for the pattern to which the `FILTER` is applied. | ||||||
</td> | ||||||
</tr> | ||||||
</tbody> | ||||||
</table> | ||||||
<div class="note"> | ||||||
<p> | ||||||
This restriction means that <a href="#defn_valuesinsertion">values inserted</a> | ||||||
do not conflict with values assigned to variables within the pattern. | ||||||
</p> | ||||||
<p> | ||||||
This operation is performed as part of query parsing. | ||||||
</p> | ||||||
</div> | ||||||
</section> | ||||||
<section> | ||||||
<h4>Remapping</h4> | ||||||
<p> | ||||||
Remapping ensures that a variable name used inside a project expression, | ||||||
but which is not part of the results of the evaluation of the project expression, | ||||||
does not coincide with a variable mentioned anywhere else in the | ||||||
algebra expression of a query. | ||||||
</p> | ||||||
<p> | ||||||
Renaming these variables does not change the results of evaluating | ||||||
the project expresssion. | ||||||
</p> | ||||||
<div class="defn"> | ||||||
<b>Definition: <span id="defn_projmap" name="defn_projmap">Projection Expression Variable Remapping</span></b> | ||||||
<p> | ||||||
For a projection algebra operation #sparqlProjection `Project(A, PV)` acting on algreg express `A` and with set of variables `PV`, define | ||||||
a partial mapping `F` from | ||||||
`<a href="#sparqlQueryVariables">V</a>`, | ||||||
the set of all variables, to `V` where: | ||||||
</p> | ||||||
<pre>F(v) = v1 if v is in PV, where v1 is a fresh variable | ||||||
F(v) = v if v is not in PV</pre> | ||||||
<p> | ||||||
Define the Projection Expression Variable Remapping `ProjectMap(P, PV)` | ||||||
</p> | ||||||
<pre>ProjectMap(Project(A, PV)) = Project(A1, PV) | ||||||
where A1 is the result of applying F | ||||||
to every variable mentioned in A. | ||||||
</pre> | ||||||
<p> | ||||||
The Projection Expression Variable Remapping yields an algrebra expression that | ||||||
evaluates to the same results as the Project argument. No variable of `ProjectMap(Project(A, PV))` | ||||||
that is not in `PV` is mentioned anywhere else in the algebra expression for the query. | ||||||
</p> | ||||||
</div> | ||||||
<p>This process is applied throughout the graph pattern of <code>EXISTS</code>:</p> | ||||||
<div class="defn"> | ||||||
<b>Definition: <span id="defn_varrename" name="defn_varrename">Variable Remapping</span></b> | ||||||
<p> | ||||||
For any algebra expression `X`, define the Variable Remapping `PrjMap(X)` | ||||||
of algebra expression `X`: | ||||||
</p> | ||||||
<pre>PrjMap(X) = replace all project operations Project(P, PV) | ||||||
with ProjectMap(P, PV) for each projection in X.</pre> | ||||||
</div> | ||||||
<p> | ||||||
The outcome of `PrjMap` is independent of the order of replacement | ||||||
(e.g. bottom-up or top-down). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Replacements may happen several times, depending on recursive order | ||||||
but each time a replacement is made, the variable not used anywhere else. | ||||||
</p> | ||||||
|
||||||
<div class="note"> | ||||||
<p> | ||||||
A variable inside a project expression that is not in the variables projected | ||||||
is not affected by the values insertion operation because it is renamed apart. | ||||||
</p> | ||||||
<p> | ||||||
This operation is as part of the <a href="#sparqlQuery">translation to the SPARQL | ||||||
algebra</a>. | ||||||
</p> | ||||||
</div> | ||||||
</section> | ||||||
<section> | ||||||
<h4>Values Insertion</h4> | ||||||
<p> | ||||||
Alternative 1: rewrite the algebra during | ||||||
<a href="#sparqlQuery">translation to the SPARQL algebra</a> | ||||||
to include a function that evaluates to the current row. | ||||||
</p> | ||||||
|
||||||
<div class="defn"> | ||||||
<div> | ||||||
<b>Definition: <span id="defn_correlate" name="defn_correlate">Values In Scope</span></b> | ||||||
<p> | ||||||
Define the function `BindingInScope()`. | ||||||
Evaluation of `BindingInScope()` results in a table of one row, | ||||||
being the current binding of the enclosing filter. | ||||||
</p> | ||||||
</div> | ||||||
</div> | ||||||
|
||||||
<div class="defn"> | ||||||
<div> | ||||||
<b>Definition: Access to the current binding</b> | ||||||
<p> | ||||||
During <a href="#sparqlQuery">translation to the SPARQL algebra</a> | ||||||
</p> | ||||||
<pre> | ||||||
Replace each occurence of `Y` in X where `Y` is one of | ||||||
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>, | ||||||
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>, | ||||||
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>, | ||||||
<a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a> | ||||||
with `join(Y, BindingInScope())`.</pre> | ||||||
</div> | ||||||
<div class="note"> | ||||||
c.f. section <a href="#sparqlTranslateGraphPatterns">Translate Graph Patterns</a> | ||||||
where an empty basic graph pattern start any | ||||||
<a href="#rGroupGraphPattern">GroupGraphPattern</a>. | ||||||
It happens before the <a href="#sparqlSimplification">simplification step</a>. | ||||||
</div> | ||||||
</div> | ||||||
|
||||||
<div class="example"> | ||||||
<p> | ||||||
Examples | ||||||
</p> | ||||||
</div> | ||||||
|
||||||
<p> | ||||||
Alternative 2: rewrite the algebra during execution. This corresponds to the | ||||||
<a href="https://github.com/w3c/sparql-dev/blob/main/SEP/SEP-0007/sep-0007.md">original SEP-0007 proposal</a>. | ||||||
</p> | ||||||
<div class="defn"> | ||||||
<div> | ||||||
<b>Definition: <span id="defn_valuesinsertion" name="defn_valuesinsertion">Values Insertion</span></b> | ||||||
<p> | ||||||
Define the Values Insertion function `ValuesInsert(X, μ)` | ||||||
</p> | ||||||
<pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1 | ||||||
|
||||||
Replace each occurence of `Y` in X where `Y` is one of | ||||||
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>, | ||||||
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>, | ||||||
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>, | ||||||
<a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a> | ||||||
with `join(Y, Table(μ))`.</pre> | ||||||
|
||||||
</div> | ||||||
</div> | ||||||
</section> | ||||||
|
||||||
<section> | ||||||
<h4>Evaluation of EXISTS</h4> | ||||||
<div class="defn"> | ||||||
<b>Definition: <span id="x-defn_evalExists" name="x-defn_evalExists">Evaluation of Exists</span></b> | ||||||
<p> | ||||||
Let `μ` be the current solution mapping for a filter, and `X` a graph pattern, | ||||||
define the Evaluation of Exists `exists(X)` | ||||||
</p> | ||||||
<pre>exists(X) = true | ||||||
if eval( D(G), ValuesInScope(PrjMap(X)), μ) | ||||||
is a non-empty solution sequence. | ||||||
exists(X) = false otherwise</pre> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The style here is that for function definition, with each case being aligned. It is not running text. |
||||||
</div> | ||||||
</section> | ||||||
</section> | ||||||
<!-- ValuesInsertion --> | ||||||
|
||||||
</section> | ||||||
|
||||||
<section id="sparqlBGPExtend"> | ||||||
<h3>Extending SPARQL Basic Graph Matching</h3> | ||||||
<p>The overall SPARQL design can be used for queries which assume a more elaborate form of | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Values Insertion
reads very oddly to me. Can this be changed (throughout) toValue Insertion
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is inserting multiple values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you use an "eggs beater" or an "egg beater"?