Skip to content
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

feat/sparql star #160

Merged
merged 41 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8eb685f
feat: wip sparqlstar
jeswr Aug 25, 2022
46c3122
chore: continue refactoring
jeswr Aug 25, 2022
3dbd206
chore: continue refactoring
jeswr Aug 25, 2022
8551d08
chore: continue refactoring
jeswr Aug 25, 2022
f873620
chore: continue refactoring
jeswr Aug 25, 2022
d16fe47
feat: wip sparqlstar
jeswr Aug 25, 2022
e03d319
chore: WIP refactor
jeswr Aug 27, 2022
be62493
WIP
jeswr Aug 28, 2022
c4e77e8
WIP
jeswr Aug 28, 2022
1854184
WIP
jeswr Aug 28, 2022
032b272
chore: temporarily add sparql-conformant
jeswr Aug 29, 2022
876bd7b
WIP
jeswr Aug 29, 2022
3a18f9e
WIP: Updating tests and working on annotations
jeswr Sep 18, 2022
be849d3
WIP: working on annotations
jeswr Sep 18, 2022
3bd8393
WIP: adding tests
jeswr Nov 14, 2022
f929b6f
WIP: give nested triples a TermType
jeswr Nov 14, 2022
1540eac
chore: fix broken parsed queries
jeswr Nov 15, 2022
efb83ee
chore: enforce no default graphs for quoted triples in tests
jeswr Nov 15, 2022
57bb1f3
chore: fix annotated blank nodes and add spec tests
jeswr Nov 15, 2022
1c7194d
chore: forward sll options in spec parser
jeswr Nov 15, 2022
791d4d5
fix: error on quoted paths
jeswr Nov 15, 2022
fe34334
chore: expand test suite
jeswr Nov 15, 2022
764a281
chore: 100% spec tests :party:
jeswr Nov 15, 2022
32da931
chore: allow annotated lists in tests
jeswr Nov 15, 2022
bfcf8b7
fix: fix list in quoted triple bug
jeswr Nov 17, 2022
89d948e
chore: remove sparql-conformant.jison
jeswr Nov 17, 2022
7571700
chore: fix broken annotation test
jeswr Nov 17, 2022
615ce44
chore: revert to using npm version of rdf-test-suite
jeswr Nov 17, 2022
a1bb4de
Merge pull request #8 from jeswr/feat/sparql-star-conformant-backup
jeswr Nov 17, 2022
a950631
chore: remove unecessary comments
jeswr Nov 17, 2022
7c07cc2
chore: merge with main
jeswr Nov 17, 2022
11bffb1
chore: add newline character to all files missing one
jeswr Nov 17, 2022
cf98455
chore: revert to package-lock from main
jeswr Nov 17, 2022
0196d86
chore: bump rdf-test-suite version
jeswr Nov 21, 2022
54628e8
chore: force audit fix
jeswr Nov 21, 2022
1281a0a
chore: add operator tests for sparql-star
jeswr Nov 25, 2022
1161ebf
chore: remove added comma from CI.yml
jeswr Nov 28, 2022
5a4014c
chore: re-inline some expressions
jeswr Jan 4, 2023
d508492
chore: fix naming
jeswr Jan 4, 2023
a8f4b46
chore: fix space alignment
jeswr Jan 5, 2023
96c5d7d
chore: fix space alignment
jeswr Jan 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
830 changes: 711 additions & 119 deletions lib/sparql.jison

Large diffs are not rendered by default.

2,721 changes: 1,043 additions & 1,678 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
"prepublishOnly": "npm run build",
"spec-base-query": "rdf-test-suite spec/parser.js http://w3c.github.io/rdf-tests/sparql11/data-sparql11/manifest-all.ttl -s http://www.w3.org/TR/sparql11-query/ -c .rdf-test-suite-cache/",
"spec-base-update": "rdf-test-suite spec/parser.js http://w3c.github.io/rdf-tests/sparql11/data-sparql11/manifest-all.ttl -s http://www.w3.org/TR/sparql11-update/ -c .rdf-test-suite-cache/",
"spec-star": "rdf-test-suite spec/parser.js https://w3c.github.io/rdf-star/tests/sparql/syntax/manifest.jsonld -i '{ \"sparqlStar\": true }' -c .rdf-test-suite-cache/",
"spec-earl-query": "npm run spec-base-query --silent -- -o earl -p spec/earl-meta.json > spec/earl-query.ttl",
"spec-earl-update": "npm run spec-base-update --silent -- -o earl -p spec/earl-meta.json > spec/earl-update.ttl",
"spec": "npm run spec-base-query && npm run spec-base-update"
"spec-earl-star": "npm run spec-star --silent -- -o earl -p spec/earl-meta.json > spec/earl-star.ttl",
"spec": "npm run spec-base-query && npm run spec-base-update && npm run spec-star"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
Expand All @@ -43,9 +45,9 @@
"devDependencies": {
"expect": "^24.9.0",
"jison": "0.4.18",
"mocha": "^7.2.0",
"mocha": "^10.1.0",
"pre-commit": "^1.2.2",
"rdf-test-suite": "^1.19.2"
"rdf-test-suite": "^1.20.0"
},
"browser": {
"_process": false,
Expand Down
2 changes: 1 addition & 1 deletion queries/sparql-skip-validation/implicit-grouping-1.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ select
(count(?y) as ?count)
{
?x ?y ?z
}
}
2 changes: 1 addition & 1 deletion queries/sparql-skip-validation/implicit-grouping-2.sparql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select ?x (count(?y) as ?count)
{
?x ?y ?z
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT * {
?s ?p ?o .
BIND([] AS ?t )
}
2 changes: 1 addition & 1 deletion queries/sparql/ask-in-anonymous-node.sparql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
BASE <ex:>
ask { [<>?o]. }
ask { [<>?o]. }
2 changes: 1 addition & 1 deletion queries/sparql/inverse-paths-anonymous-node.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ WHERE {
rdfs:label "Brad Pitt"@en ;
^dbpedia-owl:starring ?otherMovie
] .
}
}
2 changes: 1 addition & 1 deletion queries/sparql/inverse-paths-in-anonymous-node-2.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ WHERE {
rdfs:label "Brad Pitt"@en ;
^dbpedia-owl:starring ?otherMovie
] .
}
}
2 changes: 1 addition & 1 deletion queries/sparql/inverse-paths-in-anonymous-node.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ WHERE {
rdfs:label "Brad Pitt"@en ;
^dbpedia-owl:starring ?otherMovie
] .
}
}
2 changes: 1 addition & 1 deletion queries/sparql/sequence-paths-in-anonymous-node.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ select * {
:a [
:a/:a :a
] .
}
}
2 changes: 1 addition & 1 deletion queries/sparql/sparql-19-a.sparql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
select ?p (count(*) as ?n) {
[ ?p [] ].
}
}
9 changes: 9 additions & 0 deletions queries/sparqlstar-annotated/sparql-star-1.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT * WHERE {
<<?s ?p ?o>> ex:author ex:Bob .
<< ex:Moscow a ex:City >> ex:author ?person .
# The list in a quoted triple is erroneous
<< _:b ex:x ( 1 2 3 ) >> ex:broken true .
}
8 changes: 8 additions & 0 deletions queries/sparqlstar-annotated/sparql-star-annotated-1.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT * WHERE {
?s ?p ?o {| ex:author ex:Bob |} .
ex:Moscow a ex:City {| ex:author ?person |} .
_:b ex:x () {| ex:broken true |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
?s :p ("abc") {| :q 123 |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
("abc") :p :o {| :q 123 |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT * WHERE {
?s1 ?p1 ?o1 {| ?p12 ?o12 |},
?o2 {| ?p22 ?o22 |},
?o3 {| ?p32 ?o32 |}.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s ?p ?o {| ?p1 ?o1 {| :p/:q ?o2 |} |}.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT * WHERE {
?s1 ?p1 ?o1 {| ?p12 ?o12 |};
?p2 ?o2 {| ?p22 ?o22 |};
?p3 ?o3 {| ?p32 ?o32 |};
}
7 changes: 7 additions & 0 deletions queries/sparqlstar-annotated/sparql-star-annotated.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SELECT * WHERE {
?s1 ?p1 ?o1 {| ?p12 ?o12 |};
?p2 ?o2 {| ?p22 ?o22 |}.

?sa1 ?p1 ?o1 {| ?p12 ?o12 |};
?p2 ?o2 {| ?p22 ?o22 |}.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s1 ?p1 ?o1 {| ?p2 ?o2 |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PREFIX : <http://example.org#>

CONSTRUCT {
?s1 ?p1 ?o1 {| :is true |}
} WHERE {
?s1 ?p1 ?o1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PREFIX : <http://example.org#>

CONSTRUCT {
?s1 ?p1 ?o1
} WHERE {
?s1 ?p1 ?o1 {| :is true |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
<<?s0 ?p0 ?o0>> ?p1 ?o1 {| ?p2 ?o2 |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
<<?s0 ?p0 ?o0>> ?p1 ?o1 {| ?p2 <<?s3 ?p3 ?o3>> |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
<<?s0 ?p0 ?o0>> ?p1 <<?s2 ?p2 ?o2>> {| ?p2 <<?s3 ?p3 ?o3>> |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
<<?s0 ?p0 <<?s2 ?p2 ?o2>>>> ?p1 ?p1 {| ?p2 <<?s3 ?p3 <<?s4 ?p4 ?o4>>>> |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s1 ?p1 ?o1 {| ?p2 ?o2, ?o3 |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s1 ?p1 ?o1 {| ?p2 ?o2; ?p3 ?o3 |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s1 ?p1 ?o1 {| ?p2 ?o2 {| ?p3 ?o3 |} |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s1 ?p1 ?o1 {| ?p2 ?o2 {| ?p3 ?o3 {| ?p4 ?o4 |} |} |}
}
3 changes: 3 additions & 0 deletions queries/sparqlstar-annotated/sparql-star-path.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s ?p ?o {| :p/:q ?oo |}.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s :p|:q ?o {| ?pp ?oo |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
:p ("abc") :o {| :q 123 |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s :p+ ?o {| ?pp ?oo |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * {
:s :p? :o {| ?p ?o |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
:s+ :p ?o {| ?pp ?oo |} .
}
5 changes: 5 additions & 0 deletions queries/sparqlstar-invalid/sparql-star-annotated-path.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s :p/:q ?o {| ?pp ?oo |}.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s1 ?p1/?p2 ?o1 {| ?p2 ?o2 |}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT * WHERE {
<<?s ?p ?o>> ex:author ex:Bob .
<< ex:Moscow a ex:City >> ex:author ?person .
# TODO: See if this should be throwing an error
<< _:b ex:x () >> ex:broken true .
}
9 changes: 9 additions & 0 deletions queries/sparqlstar-invalid/sparql-star-list-2.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT * WHERE {
<<?s ?p ?o>> ex:author ex:Bob .
<< ex:Moscow a ex:City >> ex:author ?person .
# TODO: See if this should be throwing an error
<< _:b ex:x ( 1 2 3 ) >> ex:broken true .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s ?p ?o {| :p/:q ?oo {| ?a ?b |} |}.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
<<s :p|:q ?o>>.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT * {
?s ?p ?o .
BIND(<< [] ?p ?o >> AS ?t )
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
<<?s [] ?o>> ?p2 ?o2 .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
<<?s :p ("abc") >> :q 123 .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
<<?s :p ("abc") >> :q 123 .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
<<?s :p ("abc") >> :q 123 .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
<<("abc") :p :o >> :q 123 .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
<<("abc") :p :o >> :q 123 .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PREFIX : <http://example.com/ns#>

SELECT * {
?s ?p ?o .
BIND(<< ?s :p/:q ?o >> AS ?t )
}
5 changes: 5 additions & 0 deletions queries/sparqlstar-invalid/sparql-star-quoted-path.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
<<?s :p/:q ?o>>.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
<<?s1 ?p1/?p2 ?o1>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT * WHERE {
<<GRAPH ?g {?s ?p ?o}>> ex:author ex:Bob .
<< GRAPH ?g {?s ?p ?o} >> ex:author ex:Bob .
<< GRAPH ex:graph {ex:Moscow a ex:City} >> ex:author ?person .
<< GRAPH ex:g2 { _:b ex:x () }>> ex:broken true .
<< GRAPH ex:g2 { _:b ex:x () } >> ex:broken true .
}
7 changes: 7 additions & 0 deletions queries/sparqlstar-operators/sparql-star-istriple.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT ?s ?p ?o WHERE {
?s ?p ?o .
FILTER(isTriple(?s))
}
7 changes: 7 additions & 0 deletions queries/sparqlstar-operators/sparql-star-object.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT (object(?s) as ?o1) WHERE {
?s ?p ?o .
FILTER(isTriple(?s))
}
7 changes: 7 additions & 0 deletions queries/sparqlstar-operators/sparql-star-predicate.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT (predicate(?s) as ?p1) WHERE {
?s ?p ?o .
FILTER(isTriple(?s))
}
7 changes: 7 additions & 0 deletions queries/sparqlstar-operators/sparql-star-subject.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT (subject(?s) as ?s1) WHERE {
?s ?p ?o .
FILTER(isTriple(?s))
}
6 changes: 6 additions & 0 deletions queries/sparqlstar-operators/sparql-star-triple.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT (triple(?s, ?p, ?o) as ?t) WHERE {
?s ?p ?o .
}
5 changes: 5 additions & 0 deletions queries/sparqlstar-spec/sparql-star-annotation-01.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
?s ?p ?o {| :r ?Z |} .
}
12 changes: 12 additions & 0 deletions queries/sparqlstar-spec/sparql-star-annotation-02.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PREFIX : <http://example.com/ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT * {
:s :p :o {| :source [ :graph <http://host1/> ;
:date "2020-01-20"^^xsd:date
] ;
?source [ :graph <http://host2/> ;
:date "2020-12-31"^^xsd:date
]
|}
}
6 changes: 6 additions & 0 deletions queries/sparqlstar-spec/sparql-star-annotation-03.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PREFIX : <http://example.com/ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT * {
:s :p <<:a :b :c>> {| ?q ?z |}
}
Loading