Skip to content

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Definitions for Values Insertion #177

wants to merge 2 commits into from

Conversation

afs
Copy link
Contributor

@afs afs commented Jan 8, 2025

A replacement for substitute.

The context is taken from SEP-0007.

Currently, all new material is in a single section.

I am submitting this PR to put the content under the WG agreement for IP and Licensing.


Preview | Diff

@afs afs changed the title Defintions for Values Insertion Definitions for Values Insertion Jan 8, 2025
@afs afs force-pushed the values-insertion branch from 3f606dd to f837588 Compare January 8, 2025 10:58
spec/index.html Outdated
This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES`
clause, and variables intrucded by `AS` in `GROUP BY`.

Extend the "in-scope" rules to include the variables in-scope from the current row:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<p>Extend the "in-scope" rules to include the variables in-scope from the current row:p>
<p>Extend the "in-scope" rules to include the variables that are in-scope for the current row:p>

spec/index.html Outdated

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
is not affected by the values insertion operation because it is renamed apart.
is not affected by the value insertion operation because it is renamed apart.

Comment on lines +10373 to +10430

Values Insertion and `EXISTS`

Copy link
Member

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) to Value Insertion?

Suggested change
<section>
<h3>Values Insertion and `EXISTS`h3>
<section>
<h3>Value Insertion and `EXISTS`h3>

Copy link
Contributor Author

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.

Copy link
Member

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"?

Copy link
Member

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"?

spec/index.html Outdated
Definition: Values Insertion

Define the Values Insertion function `ValuesInsert(X, μ)`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If, as I suggested above, Values Insertion is being changed to Value Insertion, then ValuesInsert should likewise be changed to ValueInsert

Suggested change
Define the Values Insertion function `ValuesInsert(X, μ)`
Define the Value Insertion function `ValueInsert(X, μ)`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is in algebra space, the syntax analogy is VALUES.

The μ can have several bindings, correlating several variables.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not simply InsertValues ?

exists(X) = true 

            
if eval( D(G), ValuesInsert(PrjMap(X), μ) )
is a non-empty solution sequence.
exists(X) = false otherwise
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exists(X) = false otherwisepre>
Otherwise, exists(X) = false.pre>

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@afs afs force-pushed the values-insertion branch 3 times, most recently from c00cb1b to a0ccbd5 Compare May 18, 2025 19:41
@pfps
Copy link
Contributor

pfps commented May 19, 2025

In my view "values insertion" is the correct phrase to use.

Comment on lines +10490 to +10495
a partial mapping `F` from
`V`,
the set of all variables, to `V` where:

F(v) = v1 if v is in PV, where v1 is a fresh variable

            
F(v) = v if v is not in PV
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering the second line of this definition, it seems to me that F is actually not partial.

If I am wrong with this assumption, can you explain which variables are mapped by F and which ones are not.

Comment on lines +10504 to +10506
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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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 A to A1, but not in PV. As a consequence, the evaluation of A1 will not even produce bindings for the projection variables.

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 F should have been as follows.

F(v) = v1 if v is mentioned in A but is not in PV , where v1 is a fresh variable

Comment on lines +10516 to +10517
PrjMap(X) = replace all project operations Project(P, PV) 

            
with ProjectMap(P, PV) for each projection in X.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the ProjectMap(P, PV) here actually meant to be ProjectMap( Project(P, PV) ) as introduced in the previous definition? If not, how is ProjectMap(P, PV) defined?

Comment on lines +10616 to +10617
if eval( D(G), ValuesInScope(PrjMap(X)), μ)
is a non-empty solution sequence.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is ValuesInScope( .. )? Where is this defined?

No matter how it is defined, there is another problem here. The formula uses the eval function with three arguments: i) D(G), ii) the output of ValuesInScope( .. ), whatever that might be, and iii) some solution mapping μ. Yet, eval is not defined for such arguments; it is defined for two arguments: i) D(G) and ii) an algebraic expression.

Comment on lines +10563 to +10568
Replace each occurence of `Y` in X where `Y` is one of
Basic Graph Pattern,
Property Path Expression,
`Graph(Var, pattern)`,
Inline Data
with `join(Y, BindingInScope())`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. What is X?
  2. Instead of Property Path Expression, do you actually mean Property Path Pattern?

@pfps
Copy link
Contributor

pfps commented May 23, 2025

I note that this PR is for deep values insertion where values are insterted into subqueries.

Comment on lines +10549 to +10551
Define the function `BindingInScope()`.
Evaluation of `BindingInScope()` results in a table of one row,
being the current binding of the enclosing filter.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EXIST can be used not only within FILTER.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where else?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bind, select expression, order by…

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@afs
Copy link
Contributor Author

afs commented May 30, 2025

I note that this PR is for deep values insertion where values are insterted into subqueries.

Only variables are "in-scope" are affected.
The renaming apart means that variables hidden by scope in subqueries are not correlated. This is a point where correlation and the requirements of parameterisation might differ.

This query has a sub-query that exposes ?o

SELECT * {
    ?s :p ?o .
    FILTER EXISTS{ SELECT ?o { :s :q ?o }}

whereas the inner ?o in

SELECT * {
    ?s :p ?o .
    FILTER EXISTS{ SELECT ?s { ?s :q :?o }}

is not correlated.

As algebra expressions:

SELECT * {
    ?s :p ?o .
    FILTER EXISTS { SELECT * { ?s :q ?z} }
SELECT * {
    ?s :p ?o .
    FILTER EXISTS { ?s :q :?z }

are the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants