diff --git a/Cargo.lock b/Cargo.lock index 228943b..d82b5cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2644,9 +2644,9 @@ dependencies = [ [[package]] name = "pgwire" -version = "0.35.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8af67f4c689d97c91fb95132942f1e05eadc765448e9ffcc16e792783286d99d" +checksum = "d331bb0eef5bc83a221c0a85b1f205bccf094d4f72a26ae1d68a1b1c535123b7" dependencies = [ "async-trait", "base64", diff --git a/Cargo.toml b/Cargo.toml index 61e526c..3ac9eaa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ bytes = "1.11.0" chrono = { version = "0.4", features = ["std"] } datafusion = { version = "50", default-features = false } futures = "0.3" -pgwire = { version = "0.35", default-features = false } +pgwire = { version = "0.36.1", default-features = false } postgres-types = "0.2" rust_decimal = { version = "1.39", features = ["db-postgres"] } tokio = { version = "1", default-features = false } diff --git a/arrow-pg/src/datatypes/df.rs b/arrow-pg/src/datatypes/df.rs index 256b1c4..d478cbe 100644 --- a/arrow-pg/src/datatypes/df.rs +++ b/arrow-pg/src/datatypes/df.rs @@ -64,7 +64,7 @@ where S: Clone, { fn get_pg_type( - pg_type_hint: Option<&Type>, + pg_type_hint: Option, inferenced_type: Option<&DataType>, ) -> PgWireResult { if let Some(ty) = pg_type_hint { @@ -80,7 +80,14 @@ where let mut deserialized_params = Vec::with_capacity(param_len); for i in 0..param_len { let inferenced_type = inferenced_types.get(i).and_then(|v| v.to_owned()); - let pg_type = get_pg_type(portal.statement.parameter_types.get(i), inferenced_type)?; + let pg_type = get_pg_type( + portal + .statement + .parameter_types + .get(i) + .and_then(|f| f.clone()), + inferenced_type, + )?; match pg_type { // enumerate all supported parameter types and deserialize the // type to ScalarValue @@ -156,6 +163,7 @@ where } Type::TIME => { let value = portal.parameter::(i, &pg_type)?; + dbg!(&value); let ns = value.map(|t| { t.num_seconds_from_midnight() as i64 * 1_000_000_000 + t.nanosecond() as i64 @@ -329,7 +337,7 @@ mod tests { use datafusion::{common::ParamValues, scalar::ScalarValue}; use pgwire::{ api::{portal::Portal, stmt::StoredStatement}, - messages::extendedquery::Bind, + messages::{data::FORMAT_CODE_BINARY, extendedquery::Bind}, }; use postgres_types::Type; @@ -337,14 +345,14 @@ mod tests { #[test] fn test_deserialise_time_params() { - let postgres_types = vec![Type::TIME]; + let postgres_types = vec![Some(Type::TIME)]; let us: i64 = 1_000_000; // 1 second let bind = Bind::new( None, None, - vec![], + vec![FORMAT_CODE_BINARY], vec![Some(Bytes::from(i64::to_be_bytes(us).to_vec()))], vec![], ); diff --git a/datafusion-postgres/src/handlers.rs b/datafusion-postgres/src/handlers.rs index 7da8fb4..c12b801 100644 --- a/datafusion-postgres/src/handlers.rs +++ b/datafusion-postgres/src/handlers.rs @@ -651,7 +651,7 @@ impl QueryParser for Parser { &self, client: &C, sql: &str, - _types: &[Type], + _types: &[Option], ) -> PgWireResult where C: ClientInfo + Unpin + Send + Sync,