I'm trying to get the table description from a Postgres database. I use ConnectorX with Arrow2 destination and I'm trying to store it in a Polars Dataframe.
Here's the connection definition:
use connectorx::prelude::*;
use polars_core;
use std::convert::TryFrom;
let source_conn = SourceConn::try_from(
"postgresql://postgres:[email protected]:5432/oceanics?cxprotocol=binary",
)
.expect("parse conn str failed");
let queries = &[CXQuery::from(
"SELECT * FROM information_schema.columns where table_name = 'spicyperfmanager'",
)];
let destination: Arrow2Destination =
get_arrow2(&source_conn, None, queries).expect("run failed");
Then I try to extract the data from the query:
let df: polars_core::frame::DataFrame = destination.polars().unwrap();
println!("{:?}", df);
But I get the following error:
error[E0308]: mismatched types
--> src/data.rs:16:45
|
16 | let df: polars_core::frame::DataFrame = destination.polars().unwrap();
| ----------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `DataFrame`, found `polars_core::frame::DataFrame`
| |
| expected due to this
|
= note: `polars_core::frame::DataFrame` and `DataFrame` have similar names, but are actually distinct types
Here's the cargo dependencies:
[dependencies]
connectorx = { version = "0.3.1", features = ["dst_arrow", "src_postgres", "dst_arrow2"] }
polars-core = "0.30.0"
I tried using the polars::prelude DataFrame, the polars-core::frame DataFrame, but I can't seem to wrap my head around what I'm doing wrong with the typing.
connectorxusespolarsv0.20.0, and it is incompatible with v0.30.0. So you actually have two versions ofpolars, and their types are incompatible.Downgrade your
polarsto v0.20.0, and it should work.Usually crates should expose the crates they import publicly to avoid situations like that, but it appears
connectorxdoes not export itspolarsorpolars_core(although it does exposepolars_io,polars_lazyandpolars_time).