Skip to content

Consider bnode graph names in evaluation of Graph #221

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

Merged
merged 3 commits into from
Jun 23, 2025
Merged

Consider bnode graph names in evaluation of Graph #221

merged 3 commits into from
Jun 23, 2025

Conversation

hartig
Copy link
Contributor

@hartig hartig commented May 17, 2025

This PR addresses #217 by extending the definition of how to evaluate GRAPH patterns such that it now also considers blank nodes as possible graph names in an RDF dataset.

Additionally, the PR:

  • changes the layout style of the changed definition such that it is consistent with the style of the other definitions in this part of the spec
  • removes the introduction of the notation Ω(x) from the beginning of Section 18.3 Basic Graph Patterns
    • (this notation was used only in the definition that this PR changes and it was also not really clear; I have replaced it by something better directly in the changed definition now)
  • removes the notation D[i] from the beginning of Section 18.5.2 Evaluation Semantics
    • (this notation was also used only in the definition that this PR changes)
  • removes the following paragraph which was placed directly below the changed definition but, in my opinion, doesn't really add anything (in fact, it is not even relevant because there can be no solution mapping that is in the result of more than one of the joins that feed into the union in the given algorithm)---but if you think it is useful to keep that paragraph, let me know and I will restore it!

The evaluation of graph uses the Union operator. The multiplicity of a solution mapping is the sum of the multiplicities of that solution mapping in each Join operation.


Preview | Diff

@hartig hartig requested review from kasei, afs, rubensworks and Tpt May 17, 2025 16:26
the result is <var>R</var>
</pre>
<p>For every |x| that is
an <a data-cite="RDF12-CONCEPTS#dfn-IRI">IRI</a> or
Copy link
Contributor

@afs afs May 18, 2025

Choose a reason for hiding this comment

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

Suggested change
an <a data-cite="RDF12-CONCEPTS#dfn-IRI">IRI</a> or
an <a data-cite="RDF12-CONCEPTS#dfn-IRI">IRI</a>,
a <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a> or

Should the definition of the evaluation of "graph" mention blank nodes?

It isn't necessary because they come in via variables but:

  1. It more clearly indicates that literal and triple terms can not be used
  2. The intuition of variable substitution applies

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 your edit suggestion is incorrect. The x in Graph(x, P) may indeed be only an IRI or a variable; not a blank node. While the algebraic syntax is not explicitly defined in the spec, it is clear from the grammar of the user-facing syntax that there can be no blank node---see the GraphGraphPatternproduction:

[62] GraphGraphPattern ::= 'GRAPH' VarOrIri GroupGraphPattern

Should the definition of the evaluation of "graph" mention blank nodes?

It isn't necessary because they come in via variables but:

  1. It more clearly indicates that literal and triple terms can not be used

Cannot be used for what exactly?

If you mean that they cannot be used as the x in the new version of this definition, I think stating that x may be an IRI or a variable (as done in this PR) is sufficient.

If you mean that they cannot be used as bindings for the variable x (in case x is a variable), I don't think that saying something like this belongs in this definition; maybe better suited for the informal text in Section 13.3 Querying the Dataset. Also, it is not entirely correct to say that literals and term maps cannot be assigned to variable x in incoming solution mappings; such solution mappings would just not survive the Join within the foreach loop. Perhaps one thing to make this more obvious would be to extend the foreach-line of the algorithm from (current form)

foreach graph name gn in D

to

foreach graph name gn in D (recall that a graph name may be an IRI or a blank node)

Would that address your concern?

  1. The intuition of variable substitution applies

I am not sure what you mean by this comment.

Copy link
Contributor

@afs afs May 20, 2025

Choose a reason for hiding this comment

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

  1. It more clearly indicates that literal and triple terms can not be used

Cannot be used for what exactly?

As graph names.

It does not cause any harm to be a little bit more general here.
The 1.1 text says "foreach IRI i in D"; the new text puts in a link so the cue isn't there.

"foreach graph name gn in D"

  1. The intuition of variable substitution applies

I am not sure what you mean by this comment.

In TriG, GRAPH _:label { ... } is legal so one can think of the query as a trig pattern, like BGPs are turtle patterns.

The variable may, visually, be defined in the query close-by.

(Yes, this actually happens when the "graph" evaluation is joined with the rest of the group graph pattern.)

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

  1. It more clearly indicates that literal and triple terms can not be used

Cannot be used for what exactly?

As graph names.

It does not cause any harm to be a little bit more general here.
The 1.1 text says "foreach IRI i in D"; the new text puts in a link so the cue isn't there.

"foreach graph name gn in D"

Now I understand your concern! I had a proposal related to that already in my previous comment: We may extend this line of the algorithm as follows.

"foreach graph name gn in D (recall that a graph name may be an IRI or a blank node)"

I think that should address your concern. Do you agree?

  1. The intuition of variable substitution applies

I am not sure what you mean by this comment.

In TriG, GRAPH _:label { ... } is legal so one can think of the query as a trig pattern, like BGPs are turtle patterns.

Right.

Do you think my proposal for the previous point addresses this one as well? Otherwise, what else would you propose to do here?

Copy link
Member

@TallTed TallTed May 29, 2025

Choose a reason for hiding this comment

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

Picking up on @afs suggestion above...

Suggested change
an <a data-cite="RDF12-CONCEPTS#dfn-IRI">IRI</a> or
an <a data-cite="RDF12-CONCEPTS#dfn-IRI">IRI</a>,
a <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a>, or

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 I have now pushed a commit (ad44a8b) with the change proposed above, extending the

"foreach graph name gn in D"

line of the algorithm to

"foreach graph name gn in D (recall that a graph name may be an IRI or a blank node)"

Does this address your concerns? Or do you still think it is better to extend the Graph operator such that its first argument can not only be an IRI or a variable but also a blank node? (I would still find that confusing because that deviates from the user syntax)

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 are you still planning to review this PR? Otherwise, I will merge it. It has approvals from all the other editors.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just noting that GRAPH _:blank (if it were legal) is always empty. Blank nodes treatment as non-distinguished variables happens in BGPs.

@w3cbot
Copy link

w3cbot commented Jun 19, 2025

This was discussed during the #rdf-star meeting on 19 June 2025.

View the transcript

w3c/sparql-query#221 and w3c/sparql-query#227

<gb> Pull Request 221 Consider bnode graph names in evaluation of Graph (by hartig)

<gb> Pull Request 227 Adds explicit definition of the algebraic syntax (by hartig)

olaf: I have two PRs on sparql-query that have been opened for a long time
… AndyS, do you still want to look at them?

AndyS: does not look controversial


@hartig hartig merged commit 2670fe7 into main Jun 23, 2025
2 checks passed
@hartig hartig deleted the Issue217 branch June 23, 2025 17:28
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.

7 participants