-
Notifications
You must be signed in to change notification settings - Fork 2
#344 [SPARQL 1.1] - Parser and AST : UUID #405
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
abdessamad-abdoun
merged 4 commits into
feature/corese-next
from
feature/344-sparql-11-parser-and-ast-uuid
May 4, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b3d223b
#344 [SPARQL 1.1] - Parser and AST : UUID
abdessamad-abdoun cb92c56
#344 [SPARQL 1.1] - Parser and AST : UUID
abdessamad-abdoun 94c407a
Remove public modifier from SparqlParserUuidTest class
remiceres 8597926
#344 [SPARQL 1.1] - Parser and AST : UUID
abdessamad-abdoun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 3 additions & 14 deletions
17
src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/ProjectionAst.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/fr/inria/corese/core/next/query/impl/sparql/ast/constraint/UuidAst.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package fr.inria.corese.core.next.query.impl.sparql.ast.constraint; | ||
|
|
||
| import fr.inria.corese.core.next.query.impl.sparql.ast.ConstraintAst; | ||
|
|
||
| /** | ||
| * Function {@code UUID()} in SPARQL 1.1 | ||
| * Returns a fresh IRI from the UUID URN scheme. | ||
| */ | ||
| public record UuidAst() implements ConstraintAst {} |
72 changes: 72 additions & 0 deletions
72
src/test/java/fr/inria/corese/core/next/query/impl/parser/SparqlParserUuidTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package fr.inria.corese.core.next.query.impl.parser; | ||
|
|
||
| import fr.inria.corese.core.next.query.impl.sparql.ast.*; | ||
| import fr.inria.corese.core.next.query.impl.sparql.ast.constraint.EqualsAst; | ||
| import fr.inria.corese.core.next.query.impl.sparql.ast.constraint.UuidAst; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertInstanceOf; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
|
||
| @DisplayName("SPARQL 1.1 - Parser and AST : UUID") | ||
| class SparqlParserUuidTest extends AbstractSparqlParserFeatureTest { | ||
|
|
||
| @Test | ||
| @DisplayName("BIND(UUID() AS ?id)") | ||
| void shouldParseUuid() { | ||
| SparqlParser parser = newParserDefault(); | ||
|
|
||
| QueryAst ast = parser.parse(""" | ||
| SELECT * WHERE { | ||
| ?s ?p ?o . | ||
| BIND(UUID() AS ?id) | ||
| } | ||
| """); | ||
|
|
||
| assertNotNull(ast); | ||
| BindAst bind = assertInstanceOf(BindAst.class, ast.whereClause().patterns().getLast()); | ||
| assertInstanceOf(UuidAst.class, bind.expression()); | ||
| assertEquals("id", bind.variable().name()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("FILTER(UUID() = ?s)") | ||
| void shouldParseUuidInFilter() { | ||
| SparqlParser parser = newParserDefault(); | ||
|
|
||
| QueryAst ast = parser.parse(""" | ||
| SELECT * WHERE { | ||
| ?s ?p ?o . | ||
| FILTER(UUID() = ?s) | ||
| } | ||
| """); | ||
|
|
||
| assertNotNull(ast); | ||
| FilterAst filter = assertInstanceOf(FilterAst.class, ast.whereClause().patterns().getLast()); | ||
| EqualsAst equals = assertInstanceOf(EqualsAst.class, filter.operator()); | ||
| assertInstanceOf(UuidAst.class, equals.getLeftArgument()); | ||
| assertEquals("s", assertInstanceOf(VarAst.class, equals.getRightArgument()).name()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("SELECT (UUID() AS ?id) ?s WHERE { ?s ?p ?o }") | ||
| void shouldParseUuidInProjectionBinding() { | ||
| SparqlParser parser = newParserDefault(); | ||
|
|
||
| QueryAst ast = parser.parse(""" | ||
| SELECT (UUID() AS ?id) ?s WHERE { | ||
| ?s ?p ?o . | ||
| } | ||
| """); | ||
|
|
||
| assertNotNull(ast); | ||
| SelectQueryAst selectAst = assertInstanceOf(SelectQueryAst.class, ast); | ||
| assertFalse(selectAst.projection().selectAll()); | ||
| assertEquals(2, selectAst.projection().variables().size()); | ||
| assertEquals("id", selectAst.projection().variables().getFirst().name()); | ||
| assertEquals("s", selectAst.projection().variables().getLast().name()); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Same as https://github.com/corese-stack/corese-core/pull/406/changes#r3072101894
Please add a test for the usage of the function as a projection binding
Ex: