w3c / sparql-dev

SPARQL dev Community Group
https://w3c.github.io/sparql-dev/
Other
123 stars 19 forks source link

Clarify that it's forbidden to "reassign" from BIND to SELECT #192

Open VladimirAlexiev opened 1 year ago

VladimirAlexiev commented 1 year ago

This query causes stack overflow on Blazegraph (see https://phabricator.wikimedia.org/T346420)

select (sum(?foo) as ?foo) {
  bind(1 as ?foo)
}

A similar query (see above link) returns useful results on GraphDB.

This query returns "No matching records found"

select (?foo+1 as ?foo) {
  bind(1 as ?foo)
}

This query returns foo=1, no problem:

select (?foo as ?foo) {
  bind(1 as ?foo)
}

So my question is: is it forbidden to "reassign" the same var from BIND to SELECT?

Reading through the spec:

So I'd say the spec is 99% clear that is forbidden, but not 100%.

VladimirAlexiev commented 1 year ago

Update from https://phabricator.wikimedia.org/T235540, which shows that the form above is 100% forbidden.

Extra info:

I think the SPARQL conformance tests should include a check that SPARQL processors return 400 Bad Request for such requests.

jpmccu commented 1 year ago

Agreed, this tripped us up when we moved from Blazegraph to Jena. Having conformance tests and reports would be helpful for this and similar issues. For instance, Jena does not reorder VALUES bindings, and will essentially ignore end-of-query VALUES. That seems to be a conformance bug, but I'm not sure if that's clear from the standard.

On Fri, Sep 15, 2023 at 11:23 AM Vladimir Alexiev @.***> wrote:

Update from https://phabricator.wikimedia.org/T235540, which shows that the form above is 100% forbidden.

Extra info:

  • rdf4j/GraphDB allows rebinding
  • Virtuoso (dbpedia) allows rebinding (see phabricator bug)
  • Blazegraph allows it for certain situations:
    • COUNT (see phabricator bug)
    • SAMPLE (see phabricator bug)
    • identity rebinding (see above)
    • expression rebinding (not aggregate): but returns no rows
  • Jena (http://sparql.org/sparql.html) returns proper "parse errors"

I think the SPARQL conformance tests should include a check that SPARQL processors return 400 Bad Request for such requests.

— Reply to this email directly, view it on GitHub https://github.com/w3c/sparql-dev/issues/192#issuecomment-1721458793, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAETCEJRUN3TP63O5CG7V4DX2RXG7ANCNFSM6AAAAAA4Z6ZAHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Jamie McCusker (she/her/hers)

Director, Data Operations Tetherless World Constellation Rensselaer Polytechnic Institute @. @.> http://tw.rpi.edu

namedgraph commented 1 year ago

@jpmccu please create a bug report with your example(s) then. https://github.com/apache/jena/issues

afs commented 1 year ago

The SPARQL 1.1 test suite is maintained by volunteers at https://github.com/w3c/rdf-tests/ Contributions are welcome and important.

I [@VladimirAlexiev] think the SPARQL conformance tests should include a check that SPARQL processors return 400 Bad Request for such requests.

Please check the test suite.

Negative syntax tests syntax-BINDscope6.rq, syntax-BINDscope7.rq and syntax-BINDscope8.rq cover the required scoping rules for BIND in https://www.w3.org/TR/sparql-query/#variableScope. Then there are test such as syntax-SELECTscope2.rq for other forms.

The SPARQL grammar section notes 12 and 13 apply at parse time. It's a parse time error.

VladimirAlexiev commented 1 year ago

@namedgraph re @jpmccu : it's a lacking feature in Blazegraph (and GraphDB), not a bug in Jena.

VladimirAlexiev commented 1 year ago

@afs thanks for your clarifications!

jpmccu commented 1 year ago

I think the point is that if this were part of the conformance test, then the GraphDB and Blazegraph folks would see it. They both use the rdf4j package for parsing SPARQL and extend their engine, so this is also a bigger issue than just them. They need to fix their bug, but if conformance tests for things like this and other issues (like VALUES ordering for Jena) were available, we would get better conformance from implementers without having to report bugs, argue, etc.

On Wed, Sep 27, 2023 at 7:38 AM Vladimir Alexiev @.***> wrote:

@namedgraph https://github.com/namedgraph re @jpmccu https://github.com/jpmccu : it's a lacking feature in Blazegraph (and GraphDB), not a bug in Jena.

— Reply to this email directly, view it on GitHub https://github.com/w3c/sparql-dev/issues/192#issuecomment-1737224807, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAETCEMTBOBHVQXVTXNIYPLX4QF5DANCNFSM6AAAAAA4Z6ZAHE . You are receiving this because you were mentioned.Message ID: @.***>

-- Jamie McCusker (she/her/hers)

Director, Data Operations Tetherless World Constellation Rensselaer Polytechnic Institute @. @.> http://tw.rpi.edu

afs commented 1 year ago

if conformance tests for things like this and other issues

@jpmccu - They are available! See https://github.com/w3c/rdf-tests/

afs commented 1 year ago

@jpmccu - Jena does reorder VALUES if semantically allowed. Please provide a test case or detailed example of what you expect and what actually happens.

jpmccu commented 1 year ago

Odd, I can't replicate it with a simple query, it might have been a corner case. I'll see if I can come across the original sometime. Sorry about that.

Jamie

On Wed, Sep 27, 2023 at 12:07 PM Andy Seaborne @.***> wrote:

@jpmccu https://github.com/jpmccu - Jena does reorder VALUES if semantically allowed. Please provide a test case or detailed example of what you expect and what actually happens.

— Reply to this email directly, view it on GitHub https://github.com/w3c/sparql-dev/issues/192#issuecomment-1737692213, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAETCEINGBCZ44PPRHDIS63X4RFN7ANCNFSM6AAAAAA4Z6ZAHE . You are receiving this because you were mentioned.Message ID: @.***>

-- Jamie McCusker (she/her/hers)

Director, Data Operations Tetherless World Constellation Rensselaer Polytechnic Institute @. @.> http://tw.rpi.edu