Skip to content

Conversation

@simonstey
Copy link
Contributor

@simonstey simonstey self-assigned this Aug 15, 2025
@simonstey simonstey linked an issue Aug 15, 2025 that may be closed by this pull request
@simonstey
Copy link
Contributor Author

Do we want to have the SPARQL function sections being populated dynamically (from https://github.com/w3c/sparql-query/blob/main/sparql-ns.ttl ) or just updated on demand?

@HolgerKnublauch
Copy link
Contributor

I am afraid the proper process would be:

  1. We create a new TTL file that owl:imports the base file
  2. In that file we add triples that are useful for rendering, e.g.:
    a) grouping by category
    b) deep links into the SPARQL spec
  3. Then the content can be created dynamically, if we have a TTL parser available.
  4. Maybe the TTL will be accepted by the sparql main document too, but I am not sure about the update cycle.

This is of course a lot of work but will be paying off on the long term because the info will be machine readable, e.g. for syntax-directed editors.

BTW the diff is huge - what happened?

@simonstey
Copy link
Contributor Author

I am afraid the proper process would be:

1. We create a new TTL file that owl:imports the base file

2. In that file we add triples that are useful for rendering, e.g.:
   a) grouping by category
   b) deep links into the SPARQL spec

3. Then the content can be created dynamically, if we have a TTL parser available.

4. Maybe the TTL will be accepted by the sparql main document too, but I am not sure about the update cycle.

This is of course a lot of work but will be paying off on the long term because the info will be machine readable, e.g. for syntax-directed editors.

BTW the diff is huge - what happened?

I messed up the formatting.. will fix that next

@afs
Copy link
Contributor

afs commented Aug 15, 2025

  1. deep links into the SPARQL spec

If contributed back to RDF & SPARQL WG, I'm sure that could get incorporated into sparql-ns.

- Introduced examples for various SPARQL functions to enhance documentation and usability.
- Added a new prefix for shnex-sparql to categorize examples.
- Updated existing functions with example usage, including arithmetic, logical, string, numeric, and date functions.
- Ensured all aggregate functions also include example usage for clarity.
@afs
Copy link
Contributor

afs commented Aug 17, 2025

SPARQL functions work on arguments that are single RDF terms. In [ sparql:agg-count ( ?values ) ] there isn't a term for ?values. (The pain of lists not being first class in RDF.)

SPARQL Aggregates tied into the way GROUP BY works (e.g. SUM(?X+1)) to produce sets - the design means the lists are solely within aggregates a don't leak out to general evaluation. SPARQL Aggregates are not directly usable as node expressions.

shnex has it's own aggregates and that's probably the way to go - I think that defining an adaption layer to get SPARQL aggregates to work is not that different from shnex's aggregates so there is no advantage to SPARQL aggregates.

shnex aggregates working on lists which integrates with the way shnex is e.g. sh:values.

[ sparql:coalesce ( ?optionalValue "default" ) ] is n-ary including a "no result" error.
It is also special because of it's error handling - ditto logical-and, and logical-or.

I don't see that node expressions can have variables other than the environment : #498 (comment)

shnex-sparql:infixOperator
a rdf:Property ;
rdfs:label "infix operator"@en ;
rdfs:comment "Indicates the infix operator symbol used in SPARQL syntax for this function, enabling conversion from functional form to infix notation."@en ;
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is infix used in node expressions?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is not but the information is useful to capture IMHO, to produce human-readable syntax.

Copy link
Contributor

Choose a reason for hiding this comment

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

That would also need infix precedence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would also need infix precedence.

which means? 🤔

@afs
Copy link
Contributor

afs commented Sep 18, 2025

s/second/seconds/ to reduce the ambiguity of "the second component of".

@HolgerKnublauch HolgerKnublauch added the Node Expressions For SHACL 1.2 Node Expressions label Oct 6, 2025
@HolgerKnublauch
Copy link
Contributor

@simonstey this will be a great contribution, but the PR has been in draft state and unchanged for several weeks. Do you need input/help to finish it?

@simonstey
Copy link
Contributor Author

@HolgerKnublauch

@simonstey this will be a great contribution, but the PR has been in draft state and unchanged for several weeks. Do you need input/help to finish it?

whoops, sry.. I'll have this PR merge-ready by next Monday!

@simonstey simonstey marked this pull request as ready for review October 27, 2025 09:25
@simonstey
Copy link
Contributor Author

@HolgerKnublauch
I rebased the document and fixed various HTML/merge commit issues. Should be good to go now. fyi, currently I only render the SPARQL functions as a table rather than fully fledged sections.

@HolgerKnublauch
Copy link
Contributor

Thanks a lot, Simon! I have made mostly cosmetic updates to your branch, which are hopefully OK.

We need to decide what to do with aggregates though. They are very different from the other functions as the don't work as in SPARQL: In a SPARQL query you would use them with a variable while in Node Expressions, the processing would work best if they receive another node expression that produces the aggregate values.

This however does not match how the other functions here work, which receive only individual values as arguments, never a list of values. Also, the shnex namespace already contains aggregates.

I suggest we delete the aggregates from our sparql: namespace.

HolgerKnublauch and others added 8 commits October 29, 2025 09:51
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
The classes sparql:Function etc are ill-defined and serve IMHO no purpose from a SHACL point of view. By replacing them with sh:ListParameterExpressionFunction we follow SHACL syntax and also make the owl:import to the external namespace unnecessary. (That owl:import does not resolve right now anyway)
These do not fit the execution model of node expressions. If people still want to use them, they can use SPARQL strings via sh:select etc.
Copy link
Contributor

@HolgerKnublauch HolgerKnublauch left a comment

Choose a reason for hiding this comment

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

To me it's good enough for now. Further refinements can and will happen in fresh tickets, when needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Node Expressions For SHACL 1.2 Node Expressions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support all SPARQL functions as Node Expressions

5 participants