shinji-san opened a new issue, #3268:
URL: https://github.com/apache/jena/issues/3268
### Version
5.4
### Feature
## Description
As I understand, in SPARQL 1.1, the `UNDEF` keyword in a `VALUES` clause
represents an unbound binding (i.e. `null`). However, when I'm calling any of
the following methods in `org.apache.jena.query.ParameterizedSparqlString`
with a `null` element, a `NullPointerException` is thrown:
```java
setValues(String valueName, Collection<? extends
org.apache.jena.rdf.model.RDFNode> items)
setValues(String valueName, org.apache.jena.rdf.model.RDFNode item)
setValues(Map<String, Collection<? extends
org.apache.jena.rdf.model.RDFNode>> itemsMap)
```
There is also no existing `RDFNode` implementation that represents the
SPARQL keyword `UNDEF`. According to the SPARQL 1.1 specification, `UNDEF` must
be allowed in a VALUES clause to represent an unbound binding.
## Actual Behavior
- A `NullPointerException` occurs
- No way to explicitly represent the `UNDEF` keyword via the API
## Expected Behavior
- No `NullPointerException` is thrown
- The generated query is valid SPARQL:
```sparql
VALUES (?x ?y) {
(:uri1 1)
(:uri2 UNDEF)
}
```
## Possible Solutions
1. Introduce an `UndefRDFNode`
- Create a class `UndefRDFNode` implements `RDFNode` whose `toString()`
returns "UNDEF".
- `ParameterizedSparqlString` detects instances of `UndefRDFNode` and
render them as `UNDEF`.
2. Treat `null` as `UNDEF`
- Modify all `setValues` methods to catch `null` entries and output
`UNDEF` instead of throwing an exception.
- Pros: No new class required.
- Cons: Overloading `null` may be confusing in other contexts.
3. Reuse an existing Node type
- Investigate if `Node.ANY` or another core Node can be repurposed to
mean unbound.
- Please note: `Node.ANY` is intended for pattern matching, not unbound
results, so semantics differ.
## Tests
Add unit tests for each overload of `setValues` method to verify that the
correct results are returned:
- Single-variable `UNDEF` case
- Mixed bindings, e.g. `( :uri1 1 )`, `( :uri2 UNDEF )`
- Multi-variable rows containing `UNDEF`
## References
- Apache JIRA: [JENA-1750](https://issues.apache.org/jira/browse/JENA-1750)
- SPARQL 1.1 Query Language: [VALUES
clause](https://www.w3.org/TR/sparql11-query/#inline-data)
### Are you interested in contributing a solution yourself?
None
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]