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

Querying online json-ld document fails in 0.8.1, ok in 0.7.0 #356

Closed
CFGrote opened this issue Apr 21, 2023 · 4 comments
Closed

Querying online json-ld document fails in 0.8.1, ok in 0.7.0 #356

CFGrote opened this issue Apr 21, 2023 · 4 comments
Assignees
Labels
Bug Something isn't working
Milestone

Comments

@CFGrote
Copy link

CFGrote commented Apr 21, 2023

Summary

Running a simple query with sparql-anything client on a online json-ld document fails if version 0.8.1 is used.

To reproduce:

run this query with sparql-anything-0.8.1.jar:

PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT distinct ?s ?p ?o where {
  service <x-sparql-anything:>
  {
    fx:properties fx:location "http://pflu.evolbio.mpg.de/web-services/content/v0.1";
                  fx:media-type "application/ld+json" .
    ?s ?p ?o .
  }
}
limit 10

The queried resource is a (public) online json-ld document.

With sparql-anything client v0.8.1, I get this trace:

$ java -jar ~/.local/share/java/sparql-anything-0.8.1.jar -q pflu_query_005.rq
[main] INFO com.github.sparqlanything.cli.SPARQLAnything - SPARQL anything
[main] INFO com.github.sparqlanything.rdf.RDFTriplifier - URL http://pflu.evolbio.mpg.de/web-services/content/v0.1
[main] ERROR com.github.sparqlanything.engine.FacadeXOpExecutor - An error occurred: java.lang.StringIndexOutOfBoundsException: Range [0, -1) out of bounds for length 19
Exception in thread "main" java.lang.RuntimeException: java.io.IOException: java.lang.StringIndexOutOfBoundsException: Range [0, -1) out of bounds for length 19        at com.github.sparqlanything.engine.FacadeXOpExecutor.execute(FacadeXOpExecutor.java:69)
        at org.apache.jena.sparql.engine.main.ExecutionDispatch.visit(ExecutionDispatch.java:203)
        at org.apache.jena.sparql.algebra.op.OpService.visit(OpService.java:56)
        at org.apache.jena.sparql.engine.main.ExecutionDispatch.exec(ExecutionDispatch.java:46)
        at org.apache.jena.sparql.engine.main.OpExecutor.exec(OpExecutor.java:118)
        at org.apache.jena.sparql.engine.main.OpExecutor.execute(OpExecutor.java:390)
        at org.apache.jena.sparql.engine.main.ExecutionDispatch.visit(ExecutionDispatch.java:267)
        at org.apache.jena.sparql.algebra.op.OpProject.visit(OpProject.java:47)
        at org.apache.jena.sparql.engine.main.ExecutionDispatch.exec(ExecutionDispatch.java:46)
        at org.apache.jena.sparql.engine.main.OpExecutor.exec(OpExecutor.java:118)
        at org.apache.jena.sparql.engine.main.OpExecutor.execute(OpExecutor.java:412)
        at org.apache.jena.sparql.engine.main.ExecutionDispatch.visit(ExecutionDispatch.java:275)
        at org.apache.jena.sparql.algebra.op.OpDistinct.visit(OpDistinct.java:47)
        at org.apache.jena.sparql.engine.main.ExecutionDispatch.exec(ExecutionDispatch.java:46)
        at org.apache.jena.sparql.engine.main.OpExecutor.exec(OpExecutor.java:118)
        at org.apache.jena.sparql.engine.main.OpExecutor.execute(OpExecutor.java:400)
        at org.apache.jena.sparql.engine.main.ExecutionDispatch.visit(ExecutionDispatch.java:307)
        at org.apache.jena.sparql.algebra.op.OpSlice.visit(OpSlice.java:50)
        at org.apache.jena.sparql.engine.main.ExecutionDispatch.exec(ExecutionDispatch.java:46)
        at org.apache.jena.sparql.engine.main.OpExecutor.exec(OpExecutor.java:118)
        at org.apache.jena.sparql.engine.main.OpExecutor.execute(OpExecutor.java:89)
        at org.apache.jena.sparql.engine.main.QC.execute(QC.java:53)
        at org.apache.jena.sparql.engine.main.QueryEngineMain.eval(QueryEngineMain.java:55)
        at org.apache.jena.sparql.engine.QueryEngineBase.evaluate(QueryEngineBase.java:176)
        at org.apache.jena.sparql.engine.QueryEngineBase.createPlan(QueryEngineBase.java:132)
        at org.apache.jena.sparql.engine.QueryEngineBase.getPlan(QueryEngineBase.java:113)
        at org.apache.jena.sparql.engine.main.QueryEngineMain$QueryEngineMainFactory.create(QueryEngineMain.java:90)
        at org.apache.jena.sparql.engine.QueryExecutionBase.getPlan(QueryExecutionBase.java:622)
        at org.apache.jena.sparql.engine.QueryExecutionBase.startQueryIterator(QueryExecutionBase.java:556)
        at org.apache.jena.sparql.engine.QueryExecutionBase.execResultSet(QueryExecutionBase.java:612)
        at org.apache.jena.sparql.engine.QueryExecutionBase.execSelect(QueryExecutionBase.java:198)
        at com.github.sparqlanything.cli.SPARQLAnything.executeQuery(SPARQLAnything.java:95)
        at com.github.sparqlanything.cli.SPARQLAnything.main(SPARQLAnything.java:512)
Caused by: java.io.IOException: java.lang.StringIndexOutOfBoundsException: Range [0, -1) out of bounds for length 19
        at com.github.sparqlanything.engine.DatasetGraphCreator.triplify(DatasetGraphCreator.java:209)
        at com.github.sparqlanything.engine.DatasetGraphCreator.getDatasetGraph(DatasetGraphCreator.java:80)
        at com.github.sparqlanything.engine.FacadeXOpExecutor.executeDefaultFacadeX(FacadeXOpExecutor.java:152)
        at com.github.sparqlanything.engine.FacadeXOpExecutor.execute(FacadeXOpExecutor.java:64)
        ... 32 more
Caused by: java.lang.StringIndexOutOfBoundsException: Range [0, -1) out of bounds for length 19
        at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)
        at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)
        at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
        at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
        at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
        at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112)
        at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349)
        at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4602)
        at java.base/java.lang.String.substring(String.java:2715)
        at com.github.sparqlanything.rdf.RDFTriplifier.getRDFLang(RDFTriplifier.java:85)
        at com.github.sparqlanything.rdf.RDFTriplifier.triplify(RDFTriplifier.java:75)
        at com.github.sparqlanything.engine.DatasetGraphCreator.triplify(DatasetGraphCreator.java:197)
        ... 35 more

Workaround

I have to go back to v0.7.0 (0.8.0 not tested) to get the expected results:

$ java -jar ~/.local/share/java/sparql-anything-0.7.0.jar -q pflu_query_005.rq
[main] INFO com.github.sparqlanything.cli.SPARQLAnything - SPARQL anything
[main] INFO com.github.sparqlanything.rdf.RDFTriplifier - URL http://pflu.evolbio.mpg.de/web-services/content/v0.1
s,p,o
http://pflu.evolbio.mpg.de/web-services/content/v0.1/Heritable_Phenotypic_Marker,http://www.w3.org/2000/01/rdf-schema#label,Heritable Phenotypic Marker Collection
http://pflu.evolbio.mpg.de/web-services/content/v0.1/Heritable_Phenotypic_Marker,http://www.w3.org/2000/01/rdf-schema#comment,A collection of Heritable Phenotypic Marker resources: a biological_region characterized as a single heritable trait in a phenotype screen. The heritable phenotype may be mapped to a chromosome but generally has not been characterized to a specific gene locus. [JAX:hdene]
http://pflu.evolbio.mpg.de/web-services/content/v0.1/Heritable_Phenotypic_Marker,http://www.w3.org/1999/02/22-rdf-syntax-ns#type,http://pflu.evolbio.mpg.de/web-services/doc/v0.1#Heritable_Phenotypic_Marker_Collection
http://pflu.evolbio.mpg.de/web-services/content/v0.1/Signal_Peptide,http://www.w3.org/2000/01/rdf-schema#label,Signal Peptide Collection
http://pflu.evolbio.mpg.de/web-services/content/v0.1/Signal_Peptide,http://www.w3.org/2000/01/rdf-schema#comment,A collection of Signal Peptide resources: the signal_peptide is a short region of the peptide located at the N-terminus that directs the protein to be secreted or part of membrane components. [http://www.insdc.org/files/feature_table.html]
http://pflu.evolbio.mpg.de/web-services/content/v0.1/Signal_Peptide,http://www.w3.org/1999/02/22-rdf-syntax-ns#type,http://pflu.evolbio.mpg.de/web-services/doc/v0.1#Signal_Peptide_Collection
http://pflu.evolbio.mpg.de/web-services/content/v0.1/mRNA,http://www.w3.org/2000/01/rdf-schema#label,mRNA Collection
http://pflu.evolbio.mpg.de/web-services/content/v0.1/mRNA,http://www.w3.org/2000/01/rdf-schema#comment,A collection of mRNA resources: messenger RNA is the intermediate molecule between DNA and protein. It includes UTR and coding sequences. It does not contain introns. [SO:ma]
http://pflu.evolbio.mpg.de/web-services/content/v0.1/mRNA,http://www.w3.org/1999/02/22-rdf-syntax-ns#type,http://pflu.evolbio.mpg.de/web-services/doc/v0.1#mRNA_Collection
http://pflu.evolbio.mpg.de/web-services/content/v0.1/Repeat_Region,http://www.w3.org/2000/01/rdf-schema#label,Repeat Region Collection

Environment:

OS: ubuntu-22.04
java:

$ java --version
openjdk 19.0.2 2023-01-17
OpenJDK Runtime Environment (build 19.0.2+7-Ubuntu-0ubuntu322.04)
OpenJDK 64-Bit Server VM (build 19.0.2+7-Ubuntu-0ubuntu322.04, mixed mode, sharing)
@enridaga enridaga self-assigned this Apr 22, 2023
@enridaga enridaga added the Bug Something isn't working label Apr 22, 2023
@enridaga enridaga added this to the v0.9.0 milestone Apr 22, 2023
@enridaga enridaga removed the Bug Something isn't working label Apr 22, 2023
@enridaga
Copy link
Member

This bug was introduced when we reworked the RDF connector after v0.8.1. The problem was solved in #317, so the next release will include the fix.

However, when I try the query with the current development version the query works from a Java Test but the result set from the CLI is empty. This needs to be investigated.

enridaga added a commit that referenced this issue Apr 22, 2023
@enridaga
Copy link
Member

This last problem was a side effect of #339 where we wanted to load files with extension .json as jsonld documents (because the -l option expects the content to be RDF)

@enridaga
Copy link
Member

The problem should be fixed in the v0.9-DEV branch. I opened #357 to leave a review of the current approach for the future, as this solution feels a bit convoluted.

@enridaga enridaga added the Bug Something isn't working label Apr 22, 2023
@enridaga
Copy link
Member

BTW thanks, @CFGrote, for using SPARQL Anything :)

@luigi-asprino luigi-asprino modified the milestones: v0.9.0, v0.8.2 May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants