oeg-upm / morph-rdb

Virtual Knowledge Graph Creation from RDB with R2RML
https://morph.oeg.fi.upm.es/tool/morph-rdb
Other
41 stars 38 forks source link

Conversion errors on doubles #32

Closed AlasdairGray closed 4 years ago

AlasdairGray commented 6 years ago

We have been using morph to convert a postgreSQL database to RDF.

In the database we have the values stored as double precision with entries such as 8.8 and 8.6. However, when these are converted by the mappings they become 8.80000000000000071 and 8.59999999999999964 respectively. This is undesirable. We want the values to remain as they appear in the database.

I suspect that this is caused by casting errors in the code. Is it something that can be fixed?

fpriyatna commented 6 years ago

Thanks Alasdair for your interest on morph-RDB, I'll take a look at this issue and will let you know as soon as I manage to solve it.

AlasdairGray commented 6 years ago

Let me know if you need any more information.

dachafra commented 4 years ago

Sorry for the late response. Please @jatoledo use an example using the Madrid-GTFS-Bench where the data has double values (for example, lat and long position of the stops), insert them as double precision in the database and test if the issue is resolved

jatoledo commented 4 years ago

Hi, This issue is not resolved E.g. Price

benchmark=# \d+ offer
    Column    |       Type        |
--------------+-------------------+
 vendor       | character varying |
 price        | double precision  |
  s   | mappingid_s |    o    | mappingid_o
------+-------------+---------+-------------
 1976 |  1064905627 | 8305.93 |     1765702
<?xml version="1.0" encoding="UTF-8"?>
<sparql>
    <head>
        <variable name="s"/>
        <variable name="o"/>
    </head>
    <results>
        <result>
            <binding name="s">
                <uri>http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/Offer1976</uri>
            </binding>
            <binding name="o">
                <literal>8305.93000000000029</literal>
            </binding>
        </result>
    </results>
</sparql>

I'll solve it as soon as possible.

jatoledo commented 4 years ago

This is an error when you try to get a String and the column is double precision. E.g

val result = rs.getString(columnName);  //8305.93000000000029

The solution is get the Object an apply toString

val result = rs.getObject(columnName).toString();//8305.93
<?xml version="1.0" encoding="UTF-8"?>
<sparql>
    <head>
        <variable name="s"/>
        <variable name="o"/>
    </head>
    <results>
        <result>
            <binding name="s">
                <uri>http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/Offer1976</uri>
            </binding>
            <binding name="o">
                <literal>8305.93</literal>
            </binding>
        </result>
    </results>
</sparql>

Thank you @AlasdairGray for report this issue. Please @dachafra or @fpriyatna accept my pull request and generate the new release.

dachafra commented 4 years ago

Thanks @jatoledo! The new release will include the solution. Issue closed. Thanks for the feedback and so sorry for the late reply @AlasdairGray !