Skip to content

Commit ad9eaa6

Browse files
authored
Merge branch 'master' into master
2 parents 2c5b550 + e8875df commit ad9eaa6

File tree

6 files changed

+74
-51
lines changed

6 files changed

+74
-51
lines changed

Cargo.lock

Lines changed: 28 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

arrow-pg/src/datatypes.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ pub fn into_pg_type(arrow_type: &DataType) -> PgWireResult<Type> {
3535
DataType::Time32(_) | DataType::Time64(_) => Type::TIME,
3636
DataType::Date32 | DataType::Date64 => Type::DATE,
3737
DataType::Interval(_) => Type::INTERVAL,
38-
DataType::Binary | DataType::FixedSizeBinary(_) | DataType::LargeBinary => Type::BYTEA,
38+
DataType::Binary
39+
| DataType::FixedSizeBinary(_)
40+
| DataType::LargeBinary
41+
| DataType::BinaryView => Type::BYTEA,
3942
DataType::Float16 | DataType::Float32 => Type::FLOAT4,
4043
DataType::Float64 => Type::FLOAT8,
4144
DataType::Decimal128(_, _) => Type::NUMERIC,
4245
DataType::Utf8 => Type::VARCHAR,
43-
DataType::LargeUtf8 => Type::TEXT,
46+
DataType::LargeUtf8 | DataType::Utf8View => Type::TEXT,
4447
DataType::List(field) | DataType::FixedSizeList(field, _) | DataType::LargeList(field) => {
4548
match field.data_type() {
4649
DataType::Boolean => Type::BOOL_ARRAY,
@@ -58,11 +61,14 @@ pub fn into_pg_type(arrow_type: &DataType) -> PgWireResult<Type> {
5861
DataType::Time32(_) | DataType::Time64(_) => Type::TIME_ARRAY,
5962
DataType::Date32 | DataType::Date64 => Type::DATE_ARRAY,
6063
DataType::Interval(_) => Type::INTERVAL_ARRAY,
61-
DataType::FixedSizeBinary(_) | DataType::Binary => Type::BYTEA_ARRAY,
64+
DataType::FixedSizeBinary(_)
65+
| DataType::Binary
66+
| DataType::LargeBinary
67+
| DataType::BinaryView => Type::BYTEA_ARRAY,
6268
DataType::Float16 | DataType::Float32 => Type::FLOAT4_ARRAY,
6369
DataType::Float64 => Type::FLOAT8_ARRAY,
6470
DataType::Utf8 => Type::VARCHAR_ARRAY,
65-
DataType::LargeUtf8 => Type::TEXT_ARRAY,
71+
DataType::LargeUtf8 | DataType::Utf8View => Type::TEXT_ARRAY,
6672
struct_type @ DataType::Struct(_) => Type::new(
6773
Type::RECORD_ARRAY.name().into(),
6874
Type::RECORD_ARRAY.oid(),
@@ -78,7 +84,6 @@ pub fn into_pg_type(arrow_type: &DataType) -> PgWireResult<Type> {
7884
}
7985
}
8086
}
81-
DataType::Utf8View => Type::TEXT,
8287
DataType::Dictionary(_, value_type) => into_pg_type(value_type)?,
8388
DataType::Struct(fields) => {
8489
let name: String = fields

arrow-pg/src/encoder.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ fn get_utf8_view_value(arr: &Arc<dyn Array>, idx: usize) -> Option<&str> {
142142
})
143143
}
144144

145+
fn get_binary_view_value(arr: &Arc<dyn Array>, idx: usize) -> Option<&[u8]> {
146+
(!arr.is_null(idx)).then(|| {
147+
arr.as_any()
148+
.downcast_ref::<BinaryViewArray>()
149+
.unwrap()
150+
.value(idx)
151+
})
152+
}
153+
145154
fn get_utf8_value(arr: &Arc<dyn Array>, idx: usize) -> Option<&str> {
146155
(!arr.is_null(idx)).then(|| {
147156
arr.as_any()
@@ -160,12 +169,15 @@ fn get_large_utf8_value(arr: &Arc<dyn Array>, idx: usize) -> Option<&str> {
160169
})
161170
}
162171

163-
fn get_binary_value(arr: &Arc<dyn Array>, idx: usize) -> Option<&[u8]> {
172+
fn get_binary_value(arr: &Arc<dyn Array>, idx: usize) -> Option<String> {
164173
(!arr.is_null(idx)).then(|| {
165-
arr.as_any()
166-
.downcast_ref::<BinaryArray>()
167-
.unwrap()
168-
.value(idx)
174+
String::from_utf8_lossy(
175+
arr.as_any()
176+
.downcast_ref::<BinaryArray>()
177+
.unwrap()
178+
.value(idx),
179+
)
180+
.to_string()
169181
})
170182
}
171183

@@ -336,6 +348,11 @@ pub fn encode_value<T: Encoder>(
336348
type_,
337349
format,
338350
)?,
351+
DataType::BinaryView => encoder.encode_field_with_type_and_format(
352+
&get_binary_view_value(arr, idx),
353+
type_,
354+
format,
355+
)?,
339356
DataType::LargeUtf8 => encoder.encode_field_with_type_and_format(
340357
&get_large_utf8_value(arr, idx),
341358
type_,
@@ -517,7 +534,8 @@ pub fn encode_value<T: Encoder>(
517534
.or_else(|| get_dict_values!(UInt64Type))
518535
.ok_or_else(|| {
519536
ToSqlError::from(format!(
520-
"Unsupported dictionary key type for value type {value_type}"
537+
"Unsupported dictionary key type for value type {value_type}"
538+
521539
))
522540
})?;
523541

datafusion-postgres/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use datafusion::prelude::SessionContext;
99

1010
pub mod auth;
1111
use getset::{Getters, Setters, WithSetters};
12+
use log::{info, warn};
1213
use pgwire::tokio::process_socket;
1314
use rustls_pemfile::{certs, pkcs8_private_keys};
1415
use rustls_pki_types::{CertificateDer, PrivateKeyDer};
@@ -101,7 +102,6 @@ pub async fn serve(
101102
// Bind to the specified host and port
102103
let server_addr = format!("{}:{}", opts.host, opts.port);
103104
let listener = TcpListener::bind(&server_addr).await?;
104-
105105
if tls_acceptor.is_some() {
106106
println!("Listening on {server_addr} with TLS encryption");
107107
} else {
@@ -119,6 +119,7 @@ pub async fn serve(
119119
tokio::spawn(async move {
120120
if let Err(e) = process_socket(socket, tls_acceptor_ref, factory_ref).await {
121121
eprintln!("Error processing socket: {e}");
122+
122123
}
123124
});
124125
}

datafusion-postgres/src/pg_catalog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,7 @@ pub fn setup_pg_catalog(
18301830
session_context
18311831
.catalog(catalog_name)
18321832
.ok_or_else(|| {
1833-
DataFusionError::Configuration(format!(
1833+
DataFusionError::Configuration(format!(
18341834
"Catalog not found when registering pg_catalog: {catalog_name}"
18351835
))
18361836
})?

flake.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)