renjin-dbi - H2 support

50 views
Skip to first unread message

erwan....@gmail.com

unread,
Jun 27, 2016, 3:30:25 AM6/27/16
to Renjin Contributors
Dear All,

I'm working on renjin-dbi to add support to H2 database engine.
I push on https://github.com/ebocher/renjin-dbi/tree/RH2_module a basic implementation. I have several problems :

- (1) I'm not able to compile the master branch. It gives me the following error from MonetDB :  "Failed to execute goal org.renjin:renjin-maven-plugin:0.7.1573:test (test) on project MonetDB.R: There were R test failures ->"


- (2) If I run only the two modules (DBI and RH2) It returns the error
"Failed to execute goal org.renjin:renjin-maven-plugin:0.7.1573:test (test) on project RH2: There were R test failures -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.renjin:renjin-maven-plugin:0.7.1573:test (test) on project RH2: There were R test failures
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)"

Note  : I run the renjin-dbi with the last renjin release without any success.

Thanks for help and all the best

Erwan


 

Alexander Bertram

unread,
Jun 27, 2016, 5:38:44 AM6/27/16
to renji...@googlegroups.com, Hannes Mühleisen
Hi Erwan,
I believe that the tests for MySQL, Oracle, Postgres all rely on having a specific database set up on the build machine. Ideally we should have a Dockerfile or vagrant set up, but that's not the case right now so I believe these will fail.

For your new H2 module, it sounds like your test is failing:

library(hamcrest)
library(RH2)

test.driver <- function() {
con <- dbConnect(RH2(), url="jdbc:h2:file:/tmp/db", username="sa", password="")
renjinDBITest(con)
}

You can check target/renjin-test-reports/ to see the output from the failing test:
Executing test.driver... FAILED
ERROR: object of type 'closure' is not subsettable
  at structure()
  at JDBC()
  at RH2()
  at dbConnect()
  at test.driver()

It looks like the error is coming from this statement:
JDBC(JDBC$new(), "H2")

The expression JDBC$new() is meant to instantiate the Java JDBC driver class, which you properly imported in your NAMESPACE file:

importClass(org.h2.Driver)

If I change the statement above to

JDBC(Driver$new(), "H2")

Then your test passes.

HTH, 
Alex

--
You received this message because you are subscribed to the Google Groups "Renjin Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email to renjin-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Erwan Bocher

unread,
Jun 27, 2016, 6:11:23 AM6/27/16
to renji...@googlegroups.com
Thanks a lot Alex.

I m a newbie with R and Renjin.

The compilation error is fixed but I have a unit test in error.

Caused by: org.h2.jdbc.JdbcSQLException: Column count does not match; SQL statement:
INSERT INTO renjintest VALUES (5,1, 3,5, 1,4, 0,2, 'setosa'), (4,9, 3, 1,4, 0,2, 'setosa'), (4,7,

I will check

-- 
Erwan Bocher
---------------------------------------------
Ingénieur de Recherche CNRS,
Laboratoire Lab-STICC – CNRS UMR 6285
Equipe DECIDE
UNIVERSITÉ DE BRETAGNE-SUD
Institut Universitaire de Technologie de Vannes
8, Rue Montaigne - BP 561 56017 Vannes Cedex
T: +33 2 97 62 64 92
W: https://cv.archives-ouvertes.fr/erwan-bocher
W: http://www.univ-ubs.fr

--
You received this message because you are subscribed to a topic in the Google Groups "Renjin Contributors" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/renjin-dev/3kM9vpKpiNc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to renjin-dev+...@googlegroups.com.

Alexander Bertram

unread,
Jun 27, 2016, 6:23:53 AM6/27/16
to renji...@googlegroups.com, Hannes Mühleisen
Looks like a locale issue - 5.1 seems to be getting formatted as "5,1" and so on. (I'm assuming from your footer that your computer locale is set to francais :-)

This might be a bug in Hannes' code: I'm not sure where the string conversion is done but I'm guessing that it's locale-sensitive. 

Alex 

sylvain....@gmail.com

unread,
Jun 27, 2016, 7:58:14 AM6/27/16
to Renjin Contributors, Hannes.M...@cwi.nl
Hi,

I'm working with Erwan and I have tested the build by changing my locale to "en_GB" and it works with success.

Thank you very much for your help!

Sylvain

Alexander Bertram

unread,
Jun 27, 2016, 8:28:03 AM6/27/16
to Renjin Contributors, Hannes.M...@cwi.nl
Great!
But it's probably an issue we want to fix properly otherwise anyone else using the package in France, NL, etc, will also face the exception :-)

I've opened an issue here:

Erwan Bocher

unread,
Jun 28, 2016, 3:08:51 AM6/28/16
to renji...@googlegroups.com, Hannes.M...@cwi.nl
I want to test it with renjin. Is there a solution to load RDBI and RH2 ?


-- 
Erwan Bocher
---------------------------------------------
Ingénieur de Recherche CNRS,
Laboratoire Lab-STICC – CNRS UMR 6285
Equipe DECIDE
UNIVERSITÉ DE BRETAGNE-SUD
Institut Universitaire de Technologie de Vannes
8, Rue Montaigne - BP 561 56017 Vannes Cedex
T: +33 2 97 62 64 92
W: https://cv.archives-ouvertes.fr/erwan-bocher
W: http://www.univ-ubs.fr

Alexander Bertram

unread,
Jun 28, 2016, 3:57:35 AM6/28/16
to renji...@googlegroups.com, Hannes.M...@cwi.nl
Hi Erwan,
You have a few options:
1) You should be able to include org.renjin.cran:RH2 in any Java project after building to test. 
2) You can write integration tests in Java or in R by adding test cases to src/test/java and src/test/R respectively
3) You can test interactively by running `mvn renjin:repl` from the H2 directory.
4) You can run `mvn install` on your project, which will copy the results to your ~/.m2/repository directory and then launch the renjin command line tool

Once you're ready, please submit a pull request and then it will get built and included in the Renjin repository so that it's available for everyone.

Best,
Alex

Erwan Bocher

unread,
Jun 28, 2016, 4:43:08 AM6/28/16
to renji...@googlegroups.com, Hannes.M...@cwi.nl
Thanks a lot.
A PR has been pushed.

-- 
Erwan Bocher
---------------------------------------------
Ingénieur de Recherche CNRS,
Laboratoire Lab-STICC – CNRS UMR 6285
Equipe DECIDE
UNIVERSITÉ DE BRETAGNE-SUD
Institut Universitaire de Technologie de Vannes
8, Rue Montaigne - BP 561 56017 Vannes Cedex
T: +33 2 97 62 64 92
W: https://cv.archives-ouvertes.fr/erwan-bocher
W: http://www.univ-ubs.fr

Erwan Bocher

unread,
Jun 29, 2016, 4:32:49 AM6/29/16
to renji...@googlegroups.com, Hannes.M...@cwi.nl
Dear Alex,

RH2 works well with a H2 database connection but however the RH2 package is not able to find the H2GIS dependencies used to manage spatial functions.

Do I have to create a new module RH2GIS that integrates all java dependencies ?.



-- 
Erwan Bocher
---------------------------------------------
Ingénieur de Recherche CNRS,
Laboratoire Lab-STICC – CNRS UMR 6285
Equipe DECIDE
UNIVERSITÉ DE BRETAGNE-SUD
Institut Universitaire de Technologie de Vannes
8, Rue Montaigne - BP 561 56017 Vannes Cedex
T: +33 2 97 62 64 92
W: https://cv.archives-ouvertes.fr/erwan-bocher
W: http://www.univ-ubs.fr

Alexander Bertram

unread,
Jun 29, 2016, 6:08:55 AM6/29/16
to renji...@googlegroups.com
Hi Erwan,
I suppose you could also add the dependencies directly to RHS2, but I can see how you would want to avoid that if the dependencies are huge. The alternative would then indeed be to create a second module that depends on your RH2 module as well as the additional GIS dependencies.

Alex

Erwan Bocher

unread,
Jun 29, 2016, 6:42:39 AM6/29/16
to renji...@googlegroups.com
Hi Alex,

I will choose the second option. I'm not familiar with R and its module dependency mechanism. I will try to start something.

Best regards.

-- 
Erwan Bocher
---------------------------------------------
Ingénieur de Recherche CNRS,
Laboratoire Lab-STICC – CNRS UMR 6285
Equipe DECIDE
UNIVERSITÉ DE BRETAGNE-SUD
Institut Universitaire de Technologie de Vannes
8, Rue Montaigne - BP 561 56017 Vannes Cedex
T: +33 2 97 62 64 92
W: https://cv.archives-ouvertes.fr/erwan-bocher
W: http://www.univ-ubs.fr

Alexander Bertram

unread,
Jun 30, 2016, 2:35:40 AM6/30/16
to renji...@googlegroups.com
Hi Erwan,
For Renjin, we've tried to align the package/module system as closely as possible with existing build tools for the JVM. So you should be able to basically clone the RH2 module and change the dependencies in the pom.xml file. 

I'm not sure that anything will need to be changed in the NAMESPACE file -- would this involve exposing more functions/methods to the R environment, or just ensuring that the GIS dependencies are on the classpath? In the latter case, you can simply leave the NAMESPACE file empty.

Best,
Alex 

Erwan Bocher

unread,
Jun 30, 2016, 3:11:36 AM6/30/16
to renji...@googlegroups.com
Dear Alex,

Thank you very much for your technical support and your advice.

The idea is just to ensure that the GIS dependencies  are on the classpath to expose the spatial functions available in a H2 "spatialized" database


cheers

-- 
Erwan Bocher
---------------------------------------------
Ingénieur de Recherche CNRS,
Laboratoire Lab-STICC – CNRS UMR 6285
Equipe DECIDE
UNIVERSITÉ DE BRETAGNE-SUD
Institut Universitaire de Technologie de Vannes
8, Rue Montaigne - BP 561 56017 Vannes Cedex
T: +33 2 97 62 64 92
W: https://cv.archives-ouvertes.fr/erwan-bocher
W: http://www.univ-ubs.fr

Erwan Bocher

unread,
Jun 30, 2016, 9:15:44 AM6/30/16
to renji...@googlegroups.com
Dear Alex,

I have just pushed a PR to add a new module RH2GIS.
https://github.com/hannesmuehleisen/renjin-dbi

Cheers.

-- 
Erwan Bocher
---------------------------------------------
Ingénieur de Recherche CNRS,
Laboratoire Lab-STICC – CNRS UMR 6285
Equipe DECIDE
UNIVERSITÉ DE BRETAGNE-SUD
Institut Universitaire de Technologie de Vannes
8, Rue Montaigne - BP 561 56017 Vannes Cedex
T: +33 2 97 62 64 92
W: https://cv.archives-ouvertes.fr/erwan-bocher
W: http://www.univ-ubs.fr

Reply all
Reply to author
Forward
0 new messages