gmantele / vollt

Java libraries implementing the IVOA protocol: ADQL, UWS and TAP
http://cdsportal.u-strasbg.fr/taptuto/
29 stars 28 forks source link

Support for numerical arrays #120

Open vforchi opened 4 years ago

vforchi commented 4 years ago

I would like to store an array in a column of my TAP_SCHEMA, but since my DBMS (SQLServer) does not support this feature, I was thinking about saving it as a comma separated string. Is it possible to tell vollt to convert the string into an array. I was looking at the JDBCTranslator, but it doesn't seem like the method convertTypeFromDB is exactly what I need.

gmantele commented 4 years ago

Indeed, this function just converts the name of the type ; it does not convert a column value. But you may still need to tell JDBCTranslator about the conversion from string (DBMS/SQL) into array (TAP/ADQL).

Anyway, the right place to look at is: tap.data.ResultSetTableIterator.formatColValue(...) You will have to extend this class and overwrite this function to also include your conversion. Of couse, this operation will have to be done only for columns you marked (somehow) as tables.

Then, you'll have to extend tap.db.JDBCConnection and overwrite createTableIterator(...) so that it returns an instance of your extended ResultSetTableIterator.

The final step is to tell your TAPFactory to return your extended JDBCConnection ; overwrite the function getConnection(...) of your TAPFactory. If you are using the configuration file, you will have to extend ConfigurableTAPFactory and give its path in your configuration file.

Sorry that it can not be easier to do. In a future release I intend to support arrays in some way (see #82 and #81 ). Your idea is interresting ; I think it could be included in VOLLT.