Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
.envrc
.vscode
.aider*
/test_env
/test_env

# OS
.DS_Store
Thumbs.db
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 29 additions & 2 deletions arrow-pg/src/datatypes/df.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ where
let value = portal.parameter::<i64>(i, &pg_type)?;
deserialized_params.push(ScalarValue::Int64(value));
}
Type::TEXT | Type::VARCHAR => {
Type::TEXT => {
let value = portal.parameter::<String>(i, &pg_type)?;
// Use Utf8View for TEXT type to match DataFusion's internal schema expectations
deserialized_params.push(ScalarValue::Utf8View(value));
}
Type::VARCHAR => {
let value = portal.parameter::<String>(i, &pg_type)?;
deserialized_params.push(ScalarValue::Utf8(value));
}
Expand Down Expand Up @@ -236,7 +241,17 @@ where
&DataType::Float64,
)));
}
Type::TEXT_ARRAY | Type::VARCHAR_ARRAY => {
Type::TEXT_ARRAY => {
let value = portal.parameter::<Vec<Option<String>>>(i, &pg_type)?;
let scalar_values: Vec<ScalarValue> = value.map_or(Vec::new(), |v| {
v.into_iter().map(ScalarValue::Utf8View).collect()
});
deserialized_params.push(ScalarValue::List(ScalarValue::new_list_nullable(
&scalar_values,
&DataType::Utf8View,
)));
}
Type::VARCHAR_ARRAY => {
let value = portal.parameter::<Vec<Option<String>>>(i, &pg_type)?;
let scalar_values: Vec<ScalarValue> = value.map_or(Vec::new(), |v| {
v.into_iter().map(ScalarValue::Utf8).collect()
Expand All @@ -262,6 +277,18 @@ where
// Store MAC addresses as strings for now
deserialized_params.push(ScalarValue::Utf8(value));
}
Type::UNKNOWN => {
// For unknown types, try to deserialize as integer first, then fallback to text
// This handles cases like NULL arithmetic where DataFusion can't infer types
match portal.parameter::<i32>(i, &Type::INT4) {
Ok(value) => deserialized_params.push(ScalarValue::Int32(value)),
Err(_) => {
// Fallback to text if integer parsing fails
let value = portal.parameter::<String>(i, &Type::TEXT)?;
deserialized_params.push(ScalarValue::Utf8View(value));
}
}
}
// TODO: add more advanced types (composite types, ranges, etc.)
_ => {
return Err(PgWireError::UserError(Box::new(ErrorInfo::new(
Expand Down
2 changes: 1 addition & 1 deletion datafusion-postgres-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async fn setup_session_context(
}

// Register pg_catalog
setup_pg_catalog(session_context, "datafusion")?;
setup_pg_catalog(session_context, "datafusion").await?;

Ok(())
}
Expand Down
1 change: 1 addition & 0 deletions datafusion-postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ futures.workspace = true
getset = "0.1"
log = "0.4"
pgwire = { workspace = true, features = ["server-api-ring", "scram"] }
regex = "1"
postgres-types.workspace = true
rust_decimal.workspace = true
tokio = { version = "1.47", features = ["sync", "net"] }
Expand Down
Loading
Loading