-
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 | ||||
---|---|---|---|---|---|---|
|
@@ -10467,7 +10467,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">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> | ||||||
Comment on lines
+10533
to
+10538
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. Considering the second line of this definition, it seems to me that If I am wrong with this assumption, can you explain which variables are mapped by |
||||||
<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. | ||||||
Comment on lines
+10547
to
+10549
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. I don't think that's true based on the current version of this definition. By the current definition, the projection variables are renamed from Is it possible that you have a mistake in the earlier part of this definition? In particular, I have the feeling that the first line of the definition of
|
||||||
</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">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> | ||||||
Comment on lines
+10559
to
+10560
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. Is the |
||||||
</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. W3C documents generally conform to US English, which uses a comma following
Suggested change
Edited to add: I prefer the comma, but I more prefer consistency, at least at the document level, if not at the document-suite level (i.e., all the RDF 1.2 & SPARQL 1.2 docs). If the group decides that some document(s) should be UK English, then that all the US vs UK variations within such chosen document(s) should be made UK. |
||||||
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">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. | ||||||
Comment on lines
+10592
to
+10594
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. EXIST can be used not only within FILTER. 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. Where else? 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. Bind, select expression, order by… 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. |
||||||
</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> | ||||||
Comment on lines
+10606
to
+10611
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.
|
||||||
</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">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">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. | ||||||
Comment on lines
+10659
to
+10660
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. What is No matter how it is defined, there is another problem here. The formula uses the eval function with three arguments: i) |
||||||
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"?
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.
In US English, if not global English, the common phrasing for such things uses the singular — "rule book" (not "rules book"), "tool box" (not "tools box"), "book shelf" (not "books shelf").
Also, is this only and always "inserting multiple values", or can it be "inserting a single value"?