File tree Expand file tree Collapse file tree 2 files changed +26
-10
lines changed Expand file tree Collapse file tree 2 files changed +26
-10
lines changed Original file line number Diff line number Diff line change 6868 } else {
6969 // Default to TEXT for untyped parameters in extended queries
7070 // This allows arithmetic operations to work with implicit casting
71- Ok ( Type :: TEXT )
71+ Ok ( Type :: UNKNOWN )
7272 }
7373 }
7474
@@ -262,10 +262,27 @@ where
262262 }
263263 // TODO: add more advanced types (composite types, ranges, etc.)
264264 _ => {
265- // Default to string/text for unsupported parameter types
266- // This allows graceful degradation instead of fatal errors
265+ // the client didn't provide type information and we are also
266+ // unable to inference the type.
267+ //
268+ // In this case we retry to resolve it as String or StringArray
267269 let value = portal. parameter :: < String > ( i, & pg_type) ?;
268- deserialized_params. push ( ScalarValue :: Utf8 ( value) ) ;
270+ if let Some ( value) = value {
271+ if value. starts_with ( '{' ) && value. ends_with ( '}' ) {
272+ // Looks like an array
273+ let items = value. trim_matches ( |c| c == '{' || c == '}' || c == ' ' ) ;
274+ let items = items. split ( ',' ) . map ( |s| s. trim ( ) ) ;
275+ let scalar_values: Vec < ScalarValue > = items
276+ . map ( |s| ScalarValue :: Utf8 ( Some ( s. to_string ( ) ) ) )
277+ . collect ( ) ;
278+
279+ deserialized_params. push ( ScalarValue :: List (
280+ ScalarValue :: new_list_nullable ( & scalar_values, & DataType :: Utf8 ) ,
281+ ) ) ;
282+ } else {
283+ deserialized_params. push ( ScalarValue :: Utf8 ( Some ( value) ) ) ;
284+ }
285+ }
269286 }
270287 }
271288 }
Original file line number Diff line number Diff line change @@ -667,6 +667,7 @@ impl ExtendedQueryHandler for DfSessionService {
667667 let param_types = plan
668668 . get_parameter_types ( )
669669 . map_err ( |e| PgWireError :: ApiError ( Box :: new ( e) ) ) ?;
670+
670671 let param_values = df:: deserialize_parameters ( portal, & ordered_param_types ( & param_types) ) ?; // Fixed: Use ¶m_types
671672
672673 let plan = plan
@@ -697,12 +698,10 @@ impl ExtendedQueryHandler for DfSessionService {
697698 } ) ?
698699 . map_err ( |e| PgWireError :: ApiError ( Box :: new ( e) ) ) ?
699700 } else {
700- match self . session_context . execute_logical_plan ( optimised) . await {
701- Ok ( df) => df,
702- Err ( e) => {
703- return Err ( PgWireError :: ApiError ( Box :: new ( e) ) ) ;
704- }
705- }
701+ self . session_context
702+ . execute_logical_plan ( optimised)
703+ . await
704+ . map_err ( |e| PgWireError :: ApiError ( Box :: new ( e) ) ) ?
706705 }
707706 } ;
708707 let resp = df:: encode_dataframe ( dataframe, & portal. result_column_format ) . await ?;
You can’t perform that action at this time.
0 commit comments