So, there’s a couple of things happening here.

Firstly, Jena’s SPARQL engine always treats FROM (and FROM NAMED) as referring 
to graphs in the local dataset.  So, it doesn’t matter that the URL in your 
FROM is a valid RDF resource on the web, Jena won’t try and load that by 
default, it just looks for a graph with that URI in the local dataset.

Nothing in the SPARQL specifications requires that these URLs be treated 
otherwise.  Some implementations choose to resolve these URIs from the web but 
that isn’t required by the standard, and from a security standpoint isn’t a 
good idea.

Secondly, the ARQ command line tool the local dataset is usually an implicit 
empty dataset if you don’t supply one.  Except as it turns out when you supply 
a FROM/FROM NAMED, in which case it tries to build one given the inputs it has. 
 In this case that’s only your query file which isn’t valid when treated as an 
RDF dataset, thus you get the big nasty stack trace you reported.  (This 
specifically may be a bug in the arq tool)

You can avoid this second problem by supplying an empty data file e.g.

 arq --query query.rq --data empty.ttl

But that will only serve to highlight the first issue, that Jena only treats 
FROM/FROM NAMED as references to graphs in the local dataset, and you’ll get an 
empty result from your query.

You are better off downloading the RDF data you want to query locally and then 
running arq and supplying both a query file and a data file.

Hope this helps,

Rob

From: Zlatareva, Neli (Computer Science) <[email protected]>
Date: Monday, 5 February 2024 at 01:40
To: [email protected] <[email protected]>
Subject: question about FROM keyword
Hi there, I am trying the following arq query from command window
(works fine if I am getting the file locally)

PREFIX ab: 
<http://learningsparql.com/ns/addressbook#<http://learningsparql.com/ns/addressbook>>
SELECT ?last ?first ?courseName
FROM <http://www.learningsparql.com/2ndeditionexamples/ex069.ttl>
WHERE
{
  ?s ab:firstName ?first ;
     ab:lastName ?last ;
     ab:takingCourse ?course .
  ?course ab:courseTitle ?courseName .
}

I am getting the following error

D:\neli\cs575Spring24>arq --query ex070mod2.rq
ERROR StatusLogger Reconfiguration failed: No configuration found for 
'73d16e93' at 'null' in 'null'
org.apache.jena.riot.RiotException: Failed to determine the content type: 
(URI=file:///D:/neli/cs575Spring24/ex070mod2.rq : stream=text/plain)
        at org.apache.jena.riot.RDFParser.parseURI(RDFParser.java:380)
        at org.apache.jena.riot.RDFParser.parse(RDFParser.java:360)
        at 
org.apache.jena.riot.RDFParserBuilder.parse(RDFParserBuilder.java:570)
        at org.apache.jena.riot.RDFDataMgr.parseFromURI(RDFDataMgr.java:737)
        at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:193)
        at 
org.apache.jena.sparql.util.DatasetUtils.addInGraphsWorker(DatasetUtils.java:200)
        at 
org.apache.jena.sparql.util.DatasetUtils.lambda$addInGraphs$0(DatasetUtils.java:181)
        at org.apache.jena.system.Txn.exec(Txn.java:77)
        at org.apache.jena.system.Txn.executeWrite(Txn.java:125)
        at 
org.apache.jena.sparql.util.DatasetUtils.addInGraphs(DatasetUtils.java:181)
        at 
org.apache.jena.sparql.util.DatasetUtils.createDatasetGraph(DatasetUtils.java:153)
        at 
org.apache.jena.sparql.util.DatasetUtils.createDatasetGraph(DatasetUtils.java:142)
        at 
org.apache.jena.sparql.engine.QueryEngineBase.prepareDataset(QueryEngineBase.java:82)
        at 
org.apache.jena.sparql.engine.QueryEngineBase.<init>(QueryEngineBase.java:58)
        at 
org.apache.jena.sparql.engine.main.QueryEngineMain.<init>(QueryEngineMain.java:45)
        at 
org.apache.jena.sparql.engine.main.QueryEngineMain$QueryEngineMainFactory.create(QueryEngineMain.java:89)
        at 
org.apache.jena.sparql.exec.QueryExecDataset.getPlan(QueryExecDataset.java:514)
        at 
org.apache.jena.sparql.exec.QueryExecDataset.startQueryIterator(QueryExecDataset.java:455)
        at 
org.apache.jena.sparql.exec.QueryExecDataset.execute(QueryExecDataset.java:170)
        at 
org.apache.jena.sparql.exec.QueryExecDataset.select(QueryExecDataset.java:164)
        at 
org.apache.jena.sparql.exec.QueryExecutionAdapter.execSelect(QueryExecutionAdapter.java:117)
        at 
org.apache.jena.sparql.exec.QueryExecutionCompat.execSelect(QueryExecutionCompat.java:99)
        at 
org.apache.jena.sparql.util.QueryExecUtils.doSelectQuery(QueryExecUtils.java:174)
        at 
org.apache.jena.sparql.util.QueryExecUtils.executeQuery(QueryExecUtils.java:106)
        at arq.query.lambda$queryExec$0(query.java:239)
        at org.apache.jena.system.Txn.exec(Txn.java:77)
        at org.apache.jena.system.Txn.executeRead(Txn.java:115)
        at arq.query.queryExec(query.java:236)
        at arq.query.exec(query.java:159)
        at org.apache.jena.cmd.CmdMain.mainMethod(CmdMain.java:87)
        at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:56)
        at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:43)
        at arq.arq.main(arq.java:28)

Your help will be greatly appreciated. I just downloaded the latest version of 
Apache-Jena and I am trying to run and test in command window.
Thank you so much.
Regards, Neli.

Neli P. Zlatareva, PhD
Professor of Computer Science
Department of Computer Science
Central Connecticut State University
New Britain, CT 06050
Phone: (860) 832-2723
Fax: (860) 832-2712
Web site: cs.ccsu.edu/~neli/

Reply via email to