Return incorrect results when query integer numbers #3804
Replies: 8 comments 23 replies
-
This is not intuitive but correct. Integer literals in SPARQL and Turtle are big integers (xsd:integer) and not xsd:int or xsd:long. BTW, if you query for |
Beta Was this translation helpful? Give feedback.
-
Does something like this work?
|
Beta Was this translation helpful? Give feedback.
-
We know Integer literals in SPARQL are xsd:integer. The issue is that since users can directly write 5 (without explicitly declaring its data type) to database, why could not query it in the same way? Actually, we can get the expected result on Apache Jena. When we query for |
Beta Was this translation helpful? Give feedback.
-
This SPARQL query can work. Obviously, RDF4j implicitly converts 5 to xsd:int in FILTER operation. |
Beta Was this translation helpful? Give feedback.
-
I'm on holiday so can't dig but we fixed something in #3025 related to this. Edit or actually we briefly considered it but then decided not to proceed. |
Beta Was this translation helpful? Give feedback.
-
I've written a draft feature proposal here: #3815 . |
Beta Was this translation helpful? Give feedback.
-
Presumably, that is with TDB1. The Jena API does the same as RDF4J - Java int 5 becomes "5"^^xsd:int. In TDB1 (only) "5"^^xsd:int, and all derived types of xsd:integer, will be stored as "5"^^xsd:integer. The original datatype xsd:int is lost. Some users, with a knowledge management perspective, prefer retaining the original datatype and use the general approach of a FILTER. Jena isn't the only system to do this. Losing "nonNegativeInteger" etc is unfortunate. TDB2 retains the datatype; it still canonicalises the lexical form "+5", "005" all become "5". |
Beta Was this translation helpful? Give feedback.
-
It depends on the storage: with an in-memory, plain, non-trandactional model, there is a value-matching in the storage itself. This is the only storage that does this. |
Beta Was this translation helpful? Give feedback.
-
Current Behavior
Write the number 5 of unspecified data type, int type, and long type to the database.
The Java code which writes the numbers to the database is:
Then query the database for the statement whose literal value is 5.
The SparQL query statement is:
The query result is empty, instead of the three number 5 in the database.
Expected Behavior
The expected query result is:
<http://JohnSmith>
<http://xmlns.com/foaf/0.1/age>
<http://Mark>
<http://xmlns.com/foaf/0.1/age>
<http://Peter>
<http://xmlns.com/foaf/0.1/age>
Steps To Reproduce
Write the following Java code to write the numbers to the database:
Execute the following query:
The corresponding Java code is:
Version
4.0.0-M1
Are you interested in contributing a solution yourself?
No response
Anything else?
No response
Beta Was this translation helpful? Give feedback.
All reactions