Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres, table with Float datatype = NULL gives exception #221

Open
MathiasVDA opened this issue Oct 31, 2023 · 4 comments
Open

Postgres, table with Float datatype = NULL gives exception #221

MathiasVDA opened this issue Oct 31, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@MathiasVDA
Copy link

Hello

I have a postgresql database with a table that I'm trying to convert into triples using RML and RMLmapper. But I get the following exception:

C:\Users\VBP8501\Git\Knowledge graph\rinf>docker run --rm -v "C:\Users\VBP8501\Git\Knowledge graph\rinf":/data rmlio/rmlmapper-java -m src/tunnel2.rml.ttl -m database_amdb.ttl -o output/tunnel2.ttl -s turtle
14:20:03.848 [main] ERROR be.ugent.rml.cli.Main               .run(416) - Cannot invoke "String.endsWith(String)" because "data" is null
14:20:03.852 [main] ERROR be.ugent.rml.cli.Main               .run(453) - Cannot invoke "String.endsWith(String)" because "data" is null
java.lang.NullPointerException: Cannot invoke "String.endsWith(String)" because "data" is null
        at be.ugent.rml.access.RDBAccess.normalizeData(RDBAccess.java:351)
        at be.ugent.rml.access.RDBAccess.getCSVInputStream(RDBAccess.java:198)
        at be.ugent.rml.access.RDBAccess.getInputStream(RDBAccess.java:114)
        at be.ugent.rml.records.CSVRecordFactory.getRecordsForCSV(CSVRecordFactory.java:145)
        at be.ugent.rml.records.CSVRecordFactory.getRecords(CSVRecordFactory.java:77)
        at be.ugent.rml.records.RecordsFactory.getRecords(RecordsFactory.java:144)
        at be.ugent.rml.records.RecordsFactory.createRecords(RecordsFactory.java:75)
        at be.ugent.rml.Executor.getRecords(Executor.java:361)
        at be.ugent.rml.Executor.executeWithFunction(Executor.java:136)
        at be.ugent.rml.Executor.execute(Executor.java:123)
        at be.ugent.rml.cli.Main.run(Main.java:412)
        at be.ugent.rml.cli.Main.main(Main.java:46)
(base) PS C:\Users\VBP8501\Git\Knowledge graph\rinf> 

I have studied that table and created a series of views that reduced the number of columns in the table until RMLMapper worked properly. I found out that when a column has datatype float8 and at least one value is NULL, then the above exception is thrown.

This the postgresql version of the database: PostgreSQL 12.14 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit

@DylanVanAssche
Copy link
Contributor

Hi!

Do you maybe have a simple example we can use to debug this?

@MathiasVDA
Copy link
Author

Here is an example. Run this query on your database:

create table sandbox.rml_test (
	id serial4 NOT NULL,
	label varchar(255) NULL,
	this_is_the_problem float8 NULL
	);
INSERT INTO sandbox.rml_test
("label")
VALUES('label1'),('label2'),('label3');

And use this rml file as input for the mapper

@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix rr:     <http://www.w3.org/ns/r2rml#> .
@prefix rdfs:   <http://www.w3.org/2000/01/rdf-schema#> .
@prefix d2rq: <http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#> .

<https://data.infrabel.be/data/Source/AMDB/JDBC> a d2rq:Database;
  d2rq:jdbcDSN "...";
  d2rq:jdbcDriver "drivers/org.postgresql.Driver";
  d2rq:username "...";
  d2rq:password "..." .

<https://data.infrabel.be/mapping/rml_test_map>
  a rr:TriplesMap;

  rml:logicalSource [
    rml:source <https://data.infrabel.be/data/Source/AMDB/JDBC>;
    rr:sqlVersion rr:SQL2008;
    rr:tableName "sandbox.rml_test"; ];

  rr:subjectMap [
    rr:template "https://data.infrabel.be/rml_test_{id}"; ];

  rr:predicateObjectMap [
    rr:predicate rdfs:label;
    rr:objectMap [ rml:reference "label" ] ].

And run this command:
docker run --rm -v "%cd%":/data rmlio/rmlmapper-java -m path_to_mapping_file -o path_to_output_file -s turtle

@DylanVanAssche
Copy link
Contributor

We will have a look, thanks for the example!
Normally, it should handle the float8 thing as datatype according to https://github.com/RMLio/rmlmapper-java/blob/master/src/main/java/be/ugent/rml/access/RDBAccess.java#L286C1-L286C27 but we will have to investigate further what is going on.

@MathiasVDA
Copy link
Author

It might be more related to the NULL value then to the data type. I haven't tested other dataypes with a NULL value

@DylanVanAssche DylanVanAssche added the bug Something isn't working label Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants