virtuoso-opensource icon indicating copy to clipboard operation
virtuoso-opensource copied to clipboard

Numerical Datatypes are inconsistent between storing and retrieval

Open BenediktHeinrichs opened this issue 3 years ago • 5 comments

Problem

We are currently experiencing a problem when storing different numerical datatypes.

When a user of us pushes an integer-like number as e.g. a xsd:decimal, such a number will be returned as a xsd:integer.

Since we are validating the input (using SHACL), it is very inconvenient that on retrieval of the data, it has changed the datatype because this breaks the validation (as it checks for the xsd:decimal datatype).

An example on this behavior

Input logic

INSERT DATA { GRAPH <https://test.com/> { 
  <https://test.com> <https://test.com/abc> "1"^^<http://www.w3.org/2001/XMLSchema#decimal> 
} }

Retrieval logic

SELECT ?s ?p ?o WHERE { GRAPH <https://test.com/> { ?s ?p ?o } }

Output

The returned datatype for the object of "1" is <http://www.w3.org/2001/XMLSchema#integer>, even though it was stored as a xsd:decimal.

Proposal

Add an option for turning off this conversion or fixing it, if this seems to be a bug.

This seems to be appearing on older versions of Virtuoso and the newest Docker release.

BenediktHeinrichs avatar Aug 02 '22 13:08 BenediktHeinrichs

We are looking into this ...

HughWilliams avatar Aug 02 '22 14:08 HughWilliams

@HughWilliams Is there any update relating to this issue?

ChantalAchterbergRWS avatar Jun 06 '23 13:06 ChantalAchterbergRWS

i just tested with the current openlink/virtuoso-opensource-7:latest docker image.

I opened an isql session and ran your INSERT query, followed by the following query to check the datatype:

SQL> sparql SELECT ?s ?p ?o (datatype (?o) as ?dt) WHERE { GRAPH <https://test.com/> { ?s ?p ?o } } ;
s                                                                                 p                                                                                 o                                                                                 dt
LONG VARCHAR                                                                      LONG VARCHAR                                                                      LONG VARCHAR                                                                      LONG VARCHAR
_______________________________________________________________________________

https://test.com                                                                  https://test.com/abc                                                              1                                                                                 http://www.w3.org/2001/XMLSchema#decimal

1 Rows. -- 2 msec.

Can you please try using the latest stable binary to make sure this issue is fixed?

If not, we need to get some more information about the SHACL tool you are using.

pkleef avatar Jun 06 '23 14:06 pkleef

@pkleef

I still have the same issue on the latest docker image.

To make it completely reproducible:

  • I created a Virtuoso instance according to Creating a sample Virtuoso instance
  • I visited http://localhost:8890/sparql-auth
  • I ran INSERT DATA { GRAPH <https://test.com/> { <https://test.com> <https://test.com/abc> "1"^^<http://www.w3.org/2001/XMLSchema#decimal> } }
  • I ran SELECT ?s ?p ?o WHERE { GRAPH <https://test.com/> { ?s ?p ?o } } and selected Turtle as the result format

Even with the query from above, the datatype gets returned as xsd:integer:

@prefix res: <http://www.w3.org/2005/sparql-results#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
_:_ a res:ResultSet .
_:_ res:resultVariable "s" , "p" , "o" , "dt" .
@prefix ns0:	<https://test.com/> .
@prefix xsd:	<http://www.w3.org/2001/XMLSchema#> .
_:_ res:solution [
      res:binding [ res:variable "s" ; res:value <https://test.com> ] ;
      res:binding [ res:variable "p" ; res:value ns0:abc ] ;
      res:binding [ res:variable "o" ; res:value 1 ] ;
      res:binding [ res:variable "dt" ; res:value xsd:integer ] ] .

BenediktHeinrichs avatar Jun 30 '23 13:06 BenediktHeinrichs

Development will have another look at this issue.

pkleef avatar Jun 30 '23 16:06 pkleef