oracle / oracle-r2dbc

R2DBC Driver for Oracle Database
https://oracle.com
Other
201 stars 42 forks source link

VECTOR Support #146

Closed Michael-A-McMahon closed 6 months ago

Michael-A-McMahon commented 6 months ago

This branch adds support for the VECTOR data type introduced in Oracle Database 23ai. It requires an update of the Oracle JDBC dependency to version 23.4.

Oracle R2DBC will use the oracle.sql.VECTOR class of Oracle JDBC as the default mapping for VECTOR data. This class provides conversions to and from numeric arrays, such as float[], so I think it will offer a good solution when integrating with ML libraries that also expose vectors as primitive numeric arrays.

Numeric arrays, such as float[] are already defined as a default mapping for ARRAY data. This default mapping appears in Section 14.1 of the R2DBC Specification. Also notable is that a byte[] would be mapped to a RAW by the underlying Oracle JDBC Driver. The need for oracle.sql.VECTOR as an intermediate mapping arises due to these existing mappings.

A new VECTOR type code is added to OracleR2dbcTypes. This type code is used by metadata classes to identify VECTOR data. This type code is also used to register OUT parameters. It can even be used for IN parameters, and this will allow users to directly bind primitive numeric arrays, without the need for an intermediate conversion to oracle.sql.VECTOR.

There is a known defect which will prevent Statement.returningGeneratedValues(String...) from returning VECTOR data. The defect will be resolved in the next release of Oracle JDBC. Strictly speaking, this means Oracle R2DBC does not fully support VECTOR, as it does not support the returningGeneratedValues method. But in all other cases, aside from returning values from DML, I think that almost-but-not-quite-full-support of VECTOR is valuable for our users. Users who need to return VECTOR from DML can use a temporary workaround which I've documented in the README.

Michael-A-McMahon commented 6 months ago

Failing tests will be resolved with https://github.com/oracle/oracle-r2dbc/pull/145 These are due to breaking changes in Oracle JDBC 23.4