Skip to content

Commit 208c010

Browse files
authored
Fix parameter type inference for untyped parameters in extended queries (#152)
- Default to TEXT type instead of throwing fatal errors for unknown parameter types - Allows arithmetic operations with untyped parameters to work through implicit casting - Unify all UTF8 Arrow variants (Utf8, LargeUtf8, Utf8View) to use TEXT type consistently - Resolves schema mismatches between TEXT/VARCHAR type expectations This fixes issues where queries like 'SELECT + ' would fail with 'Unknown parameter type' errors when DataFusion couldn't infer the parameter types from context.
1 parent effa5d0 commit 208c010

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

arrow-pg/src/datatypes.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ pub fn into_pg_type(arrow_type: &DataType) -> PgWireResult<Type> {
4242
DataType::Float16 | DataType::Float32 => Type::FLOAT4,
4343
DataType::Float64 => Type::FLOAT8,
4444
DataType::Decimal128(_, _) => Type::NUMERIC,
45-
DataType::Utf8 => Type::VARCHAR,
46-
DataType::LargeUtf8 | DataType::Utf8View => Type::TEXT,
45+
DataType::Utf8 | DataType::LargeUtf8 | DataType::Utf8View => Type::TEXT,
4746
DataType::List(field) | DataType::FixedSizeList(field, _) | DataType::LargeList(field) => {
4847
match field.data_type() {
4948
DataType::Boolean => Type::BOOL_ARRAY,
@@ -67,8 +66,7 @@ pub fn into_pg_type(arrow_type: &DataType) -> PgWireResult<Type> {
6766
| DataType::BinaryView => Type::BYTEA_ARRAY,
6867
DataType::Float16 | DataType::Float32 => Type::FLOAT4_ARRAY,
6968
DataType::Float64 => Type::FLOAT8_ARRAY,
70-
DataType::Utf8 => Type::VARCHAR_ARRAY,
71-
DataType::LargeUtf8 | DataType::Utf8View => Type::TEXT_ARRAY,
69+
DataType::Utf8 | DataType::LargeUtf8 | DataType::Utf8View => Type::TEXT_ARRAY,
7270
struct_type @ DataType::Struct(_) => Type::new(
7371
Type::RECORD_ARRAY.name().into(),
7472
Type::RECORD_ARRAY.oid(),

arrow-pg/src/datatypes/df.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,9 @@ where
6666
} else if let Some(infer_type) = inferenced_type {
6767
into_pg_type(infer_type)
6868
} else {
69-
Err(PgWireError::UserError(Box::new(ErrorInfo::new(
70-
"FATAL".to_string(),
71-
"XX000".to_string(),
72-
"Unknown parameter type".to_string(),
73-
))))
69+
// Default to TEXT for untyped parameters in extended queries
70+
// This allows arithmetic operations to work with implicit casting
71+
Ok(Type::TEXT)
7472
}
7573
}
7674

0 commit comments

Comments
 (0)