Skip to content

Add sh:SPARQLFunction #314

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

Closed
HolgerKnublauch opened this issue Mar 8, 2025 · 3 comments · Fixed by #370
Closed

Add sh:SPARQLFunction #314

HolgerKnublauch opened this issue Mar 8, 2025 · 3 comments · Fixed by #370
Assignees
Labels
SPARQL For SHACL 1.2 SPARQL extensions spec
Milestone

Comments

@HolgerKnublauch
Copy link
Contributor

SHACL-AF include vocabulary to declare new (SPARQL) functions: https://w3c.github.io/shacl/shacl-af/#functions

The SHACL-SPARQL 1.2 spec should include this feature. In TopBraid we have supported this for many years and it has proven to be very useful for encapsulating reusable query snippets.

@HolgerKnublauch HolgerKnublauch added the SPARQL For SHACL 1.2 SPARQL extensions spec label Mar 8, 2025
@HolgerKnublauch HolgerKnublauch self-assigned this Mar 8, 2025
@tpluscode
Copy link
Contributor

I have been thinking about function expressions and their relation to SPARQL.

SHACL-AF also has the Function Expression and https://datashapes.org/sparql# exists which defines many sh:Function (not sh:SPARQLFunction, despite its name)

IMO, we should have a more generalised set of function expressions (as in the dash-sparql namespace) which can be implemented and executed both with and without SPARQL.

The role of SHACL-SPARQL would then be to defined how each such function is implemented with SPARQL (if supported)

@HolgerKnublauch
Copy link
Contributor Author

I guess now that we will introduce a general extension mechanism for user-defined NEs, we no longer really need sh:SPARQLFunction. The remaining work items here would be to:

  • define that any List Parameter Expressions (including user-defined ones from the shapes graph) need to get exposed as SPARQL functions. Do we agree to do that (e.g. @afs)?
  • change sh:select and sh:eval so that they turn any variable from the scope into pre-bound variables. This will allow using them for user-defined NEs.

@afs
Copy link
Contributor

afs commented Mar 26, 2025

I guess now that we will introduce a general extension mechanism for user-defined NEs, we no longer really need sh:SPARQLFunction. The remaining work items here would be to:

  • define that any List Parameter Expressions (including user-defined ones from the shapes graph) need to get exposed as SPARQL functions. Do we agree to do that (e.g. @afs)?

+1

  • change sh:select and sh:eval so that they turn any variable from the scope into pre-bound variables. This will allow using them for user-defined NEs.

+1

I'll put a comment on #328 about evalExpr.

The degree of compatibility with SHACL-AF in the wild is something this group needs to think about.

There should be some respect to the ease of transition to SHACL 1.2 - which might be legacy/deprecation while respecting the syntax (application investment).

In the case of sh:SPARQLFunction, my feeling is that this isn't desirable. We can come back later and revisit that, but NE are a big change and sh:SPARQLFunction shouldn't constrain the design.

HolgerKnublauch added a commit that referenced this issue Apr 22, 2025
HolgerKnublauch added a commit that referenced this issue Apr 22, 2025
HolgerKnublauch added a commit that referenced this issue May 2, 2025
…essions now pre-bind all scope vars (#370)

Closes #314

* #314: Made focusNode an explicit param of exprEval, SPARQL-based expressions now pre-bind all scope vars

* #314: Fixes

* #314: Clarified role of active graph

* #314: active graph -> focus graph

* Apply suggestions from code review

Co-authored-by: Ted Thibodeau Jr <[email protected]>

* Updated sh:expression to [ true ] list instead of "or" semantics

---------

Co-authored-by: Ted Thibodeau Jr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SPARQL For SHACL 1.2 SPARQL extensions spec
Projects
None yet
4 participants