tokio-rs / rdbc

Rust DataBase Connectivity (RDBC) :: Common Rust API for database drivers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for vectors and complex data types

tglman opened this issue · comments

Hi,

Would be cool have support for other DBMS not strictly purely SQL based DBMS, the API defined so far are generic enough that could be used also with some NoSql DBMS, the missing part at this stage I think is the support for more advanced types, in the specific I think would be enough to add a collection type so adding to ResultSet:

    fn get_vec_i8(&self, i: u64) -> Result<Option<Vec<i8>>>;
    fn get_vec_i16(&self, i: u64) -> Result<Option<Vec<i16>>>;
    fn get_vec_i32(&self, i: u64) -> Result<Option<Vec<i32>>>;
    fn get_vec_i64(&self, i: u64) -> Result<Option<Vec<i64>>>;
    fn get_vec_f32(&self, i: u64) -> Result<Option<Vec<f32>>>;
    fn get_vec_f64(&self, i: u64) -> Result<Option<Vec<f64>>>;
    fn get_vec_string(&self, i: u64) -> Result<Option<Vec<String>>>;
    fn get_vec_bytes(&self, i: u64) -> Result<Option<Vec<Vec<u8>>>>;

As well adding a sort of nested type

   // ResultSet
   fn get_vec_value(&self, i: u64) -> Result<Option<Vec<Value>>>;
   fn get_vec_value(&self, i: u64) -> Result<Option<Value>>;
  // Nested Type
  trait Value {
     //Same signatures of ResultSet for access values
  }

Another important part i think is the named access to values, often there is also a name associate to a value and may not be there at all a position.
So maybe would be cool to have also the relative methods:

    fn get_named_i8(&self, name: &str) -> Result<Option<i8>>;
    // And all the other types combinations.

If you are interested to this I can also write a PR for this cases.
Regards

I went through a similar effort with Apache Arrow and there is a DataType enum there that supports structured types. Maybe we can take some inspiration from that.

https://github.com/apache/arrow/blob/master/rust/arrow/src/datatypes.rs#L53-L81