@@ -13,11 +13,8 @@ use pgwire::api::auth::noop::NoopStartupHandler;
1313use pgwire:: api:: auth:: StartupHandler ;
1414use pgwire:: api:: portal:: { Format , Portal } ;
1515use pgwire:: api:: query:: { ExtendedQueryHandler , SimpleQueryHandler } ;
16- use pgwire:: api:: results:: {
17- DescribePortalResponse , DescribeResponse , DescribeStatementResponse , Response , Tag ,
18- } ;
16+ use pgwire:: api:: results:: { FieldInfo , Response , Tag } ;
1917use pgwire:: api:: stmt:: QueryParser ;
20- use pgwire:: api:: stmt:: StoredStatement ;
2118use pgwire:: api:: { ClientInfo , ErrorHandler , PgWireServerHandlers , Type } ;
2219use pgwire:: error:: { PgWireError , PgWireResult } ;
2320use pgwire:: types:: format:: FormatOptions ;
@@ -202,58 +199,6 @@ impl ExtendedQueryHandler for DfSessionService {
202199 self . parser . clone ( )
203200 }
204201
205- async fn do_describe_statement < C > (
206- & self ,
207- _client : & mut C ,
208- target : & StoredStatement < Self :: Statement > ,
209- ) -> PgWireResult < DescribeStatementResponse >
210- where
211- C : ClientInfo + Unpin + Send + Sync ,
212- {
213- if let ( _, Some ( ( _, plan) ) ) = & target. statement {
214- let schema = plan. schema ( ) ;
215- let fields =
216- arrow_schema_to_pg_fields ( schema. as_arrow ( ) , & Format :: UnifiedBinary , None ) ?;
217- let params = plan
218- . get_parameter_types ( )
219- . map_err ( |e| PgWireError :: ApiError ( Box :: new ( e) ) ) ?;
220-
221- let mut param_types = Vec :: with_capacity ( params. len ( ) ) ;
222- for param_type in ordered_param_types ( & params) . iter ( ) {
223- // Fixed: Use ¶ms
224- if let Some ( datatype) = param_type {
225- let pgtype = into_pg_type ( datatype) ?;
226- param_types. push ( pgtype) ;
227- } else {
228- param_types. push ( Type :: UNKNOWN ) ;
229- }
230- }
231-
232- Ok ( DescribeStatementResponse :: new ( param_types, fields) )
233- } else {
234- Ok ( DescribeStatementResponse :: no_data ( ) )
235- }
236- }
237-
238- async fn do_describe_portal < C > (
239- & self ,
240- _client : & mut C ,
241- target : & Portal < Self :: Statement > ,
242- ) -> PgWireResult < DescribePortalResponse >
243- where
244- C : ClientInfo + Unpin + Send + Sync ,
245- {
246- if let ( _, Some ( ( _, plan) ) ) = & target. statement . statement {
247- let format = & target. result_column_format ;
248- let schema = plan. schema ( ) ;
249- let fields = arrow_schema_to_pg_fields ( schema. as_arrow ( ) , format, None ) ?;
250-
251- Ok ( DescribePortalResponse :: new ( fields) )
252- } else {
253- Ok ( DescribePortalResponse :: no_data ( ) )
254- }
255- }
256-
257202 async fn do_query < C > (
258203 & self ,
259204 client : & mut C ,
@@ -433,6 +378,48 @@ impl QueryParser for Parser {
433378 . map_err ( |e| PgWireError :: ApiError ( Box :: new ( e) ) ) ?;
434379 Ok ( ( query, Some ( ( statement, logical_plan) ) ) )
435380 }
381+
382+ fn get_parameter_types ( & self , stmt : & Self :: Statement ) -> PgWireResult < Vec < Type > > {
383+ if let ( _, Some ( ( _, plan) ) ) = stmt {
384+ let params = plan
385+ . get_parameter_types ( )
386+ . map_err ( |e| PgWireError :: ApiError ( Box :: new ( e) ) ) ?;
387+
388+ let mut param_types = Vec :: with_capacity ( params. len ( ) ) ;
389+ for param_type in ordered_param_types ( & params) . iter ( ) {
390+ // Fixed: Use ¶ms
391+ if let Some ( datatype) = param_type {
392+ let pgtype = into_pg_type ( datatype) ?;
393+ param_types. push ( pgtype) ;
394+ } else {
395+ param_types. push ( Type :: UNKNOWN ) ;
396+ }
397+ }
398+
399+ Ok ( param_types)
400+ } else {
401+ Ok ( vec ! [ ] )
402+ }
403+ }
404+
405+ fn get_result_schema (
406+ & self ,
407+ stmt : & Self :: Statement ,
408+ column_format : Option < & Format > ,
409+ ) -> PgWireResult < Vec < FieldInfo > > {
410+ if let ( _, Some ( ( _, plan) ) ) = stmt {
411+ let schema = plan. schema ( ) ;
412+ let fields = arrow_schema_to_pg_fields (
413+ schema. as_arrow ( ) ,
414+ column_format. unwrap_or ( & Format :: UnifiedBinary ) ,
415+ None ,
416+ ) ?;
417+
418+ Ok ( fields)
419+ } else {
420+ Ok ( vec ! [ ] )
421+ }
422+ }
436423}
437424
438425fn ordered_param_types ( types : & HashMap < String , Option < DataType > > ) -> Vec < Option < & DataType > > {
0 commit comments