sfu-db / connector-x

Fastest library to load data from DB to DataFrames in Rust and Python
https://sfu-db.github.io/connector-x
MIT License
1.85k stars 146 forks source link

Unable to read SQL Table with _date array: thread '<unnamed>' panicked at 'not implemented: _date', #547

Open Buedenbender opened 9 months ago

Buedenbender commented 9 months ago

What language are you using?

Python

What version are you using?

(connectorx: 0.3.2)

What database are you using?

PostgresSQL

What dataframe are you using?

Polars

Can you describe your bug?

I would like to query an SQL (Postgres) table that contains a _date columns (array of dates). I use polars for the query read_database

What are the steps to reproduce the behavior?

Create exemplary data in SQL (postgres)

create table test_polars (
        arr_date _date
);

insert into test_polars 
values
        (array ['2023-01-01'::date,'2023-03-01'::date])
;

select * from test_polars;

Try to read data with read_database

import polars as pl

pl.read_database("select * FROM test_polars",url)

# Teseted with connectorx directly aswell
import connectorx as cx
cx.read_sql(url, query)

What is the error?

thread '<unnamed>' panicked at 'not implemented: _date', /__w/connector-x/connector-x/connectorx/src/sources/postgres/typesystem.rs:108:22
stack backtrace:
   0: rust_begin_unwind
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/panicking.rs:67:14
   2: <connectorx::sources::postgres::typesystem::PostgresTypeSystem as core::convert::From<&postgres_types::Type>>::from
   3: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
   4: <connectorx::sources::postgres::PostgresSource<P,C> as connectorx::sources::Source>::fetch_metadata
   5: connectorx::dispatcher::Dispatcher<S,D,TP>::run
   6: connectorx::get_arrow2::get_arrow2
   7: connectorx::arrow2::write_arrow
   8: connectorx::read_sql::read_sql
   9: std::panicking::try
  10: connectorx::__pyo3_raw_read_sql
  11: <unknown>
  12: _PyEval_EvalFrameDefault
  13: _PyFunction_Vectorcall
  14: _PyEval_EvalFrameDefault
  15: _PyFunction_Vectorcall
  16: _PyEval_EvalFrameDefault
  17: _PyFunction_Vectorcall
  18: PyObject_Call
  19: _PyEval_EvalFrameDefault
  20: _PyFunction_Vectorcall
  21: _PyEval_EvalFrameDefault
  22: _PyFunction_Vectorcall
  23: _PyEval_EvalFrameDefault
  24: <unknown>
  25: PyEval_EvalCode
  26: <unknown>
  27: <unknown>
  28: <unknown>
  29: _PyRun_SimpleFileObject
  30: _PyRun_AnyFileObject
  31: Py_RunMain
  32: Py_BytesMain
  33: <unknown>
  34: __libc_start_main
  35: _start
Jordan-M-Young commented 2 months ago

Hey @Buedenbender. I solved a similar issue awhile back with this PR. It was for implementing varchar arrays but i think the strategy would work for date arrays too if you're interested in making a PR. Otherwise I'm happy to take a crack at this.

Buedenbender commented 2 months ago

Hi @Jordan-M-Young unfortunately I will not be able to create PR.

I would be more than happy to buy you a coffee if you could create one and implement it. I know a few other folks who are waiting for this.