apache / jena

Apache Jena
https://jena.apache.org/
Apache License 2.0
1.12k stars 652 forks source link

is this valid sparql or does qparse have a bug? #2864

Open justin2004 opened 2 days ago

justin2004 commented 2 days ago

Version

5.2.0

Question

I am able to run this query but qparse can't parse it.

PREFIX ex:    <http://foobar.com/resource/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xyz:    <http://sparql.xyz/facade-x/data/>
select *
where {
?s ex:id ?id .
?s ex:name ?name .
bind(iri(concat(str(ex:),"person_",str(MD5(concat(?id,?name))))) as ?thing)
}
$ ~/Downloads/apache-jena-5.2.0/bin/qparse --query query.rq
org.apache.jena.sparql.sse.builders.SSE_ExprBuildException: [5,107]: No known symbol for MD5
        at org.apache.jena.sparql.sse.builders.BuilderLib.exception(BuilderLib.java:117)
        at org.apache.jena.sparql.sse.builders.BuilderLib.broken(BuilderLib.java:122)
        at org.apache.jena.sparql.sse.builders.BuilderLib.broken(BuilderLib.java:109)
        at org.apache.jena.sparql.sse.builders.BuilderExpr.buildExpr(BuilderExpr.java:134)
        at org.apache.jena.sparql.sse.builders.BuilderExpr.buildExpr(BuilderExpr.java:194)
        at org.apache.jena.sparql.sse.builders.BuilderExpr.lambda$static$18(BuilderExpr.java:377)
        at org.apache.jena.sparql.sse.builders.BuilderExpr.buildExpr(BuilderExpr.java:135)
        at org.apache.jena.sparql.sse.builders.BuilderExpr.buildExpr(BuilderExpr.java:194)
        at org.apache.jena.sparql.sse.builders.BuilderExpr.buildExprListUntagged(BuilderExpr.java:84)
        at org.apache.jena.sparql.sse.builders.BuilderExpr.lambda$static$62(BuilderExpr.java:655)
        at org.apache.jena.sparql.sse.builders.BuilderExpr.buildExpr(BuilderExpr.java:135)
        at org.apache.jena.sparql.sse.builders.BuilderExpr.buildExpr(BuilderExpr.java:194)
        at org.apache.jena.sparql.sse.builders.BuilderExpr.lambda$static$72(BuilderExpr.java:734)
        at org.apache.jena.sparql.sse.builders.BuilderExpr.buildExpr(BuilderExpr.java:135)
        at org.apache.jena.sparql.sse.builders.BuilderExpr.buildExpr(BuilderExpr.java:194)
        at org.apache.jena.sparql.sse.builders.BuilderExpr.buildNamedExpr(BuilderExpr.java:158)
        at org.apache.jena.sparql.sse.builders.BuilderExpr.buildNamedExprList(BuilderExpr.java:108)
        at org.apache.jena.sparql.sse.builders.BuilderExpr.buildNamedExprOrExprList(BuilderExpr.java:100)
        at org.apache.jena.sparql.sse.builders.BuilderOp.lambda$new$30(BuilderOp.java:586)
        at org.apache.jena.sparql.sse.builders.BuilderOp.build(BuilderOp.java:131)
        at org.apache.jena.sparql.sse.builders.BuilderOp.build(BuilderOp.java:60)
        at org.apache.jena.sparql.algebra.Algebra.parse(Algebra.java:111)
        at org.apache.jena.sparql.algebra.Algebra.parse(Algebra.java:102)
        at org.apache.jena.sparql.sse.SSE.parseOp(SSE.java:337)
        at org.apache.jena.sparql.util.QueryUtils.checkOp(QueryUtils.java:52)
        at org.apache.jena.sparql.util.QueryUtils.checkQuery(QueryUtils.java:39)
        at arq.qparse.exec(qparse.java:158)
        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.qparse.main(qparse.java:66)
justin2004 commented 2 days ago

even this fails:

bind(md5(?id) as ?ll)
afs commented 1 day ago

@justin2004 Thank you for the report.

qparse does more than just parse a query - it parses it, checks it converts to the algebra, converts both query and algebra to a to a string and reparses both of them. It's the parse-algebra last step on the algebra that's failing because the algebra function name has been written in upper case.

Weirdly - this has never worked.

I traced git back to the dawn of time [] and it's wrong there as well. MD5 and SHA.

[*] or May 2012 as it's also known, when Jena became a top-level project at Apache (in svn).