alamb commented on code in PR #10432: URL: https://github.com/apache/datafusion/pull/10432#discussion_r1595344465
########## datafusion-examples/examples/flight/flight_sql_server.rs: ########## @@ -246,27 +276,6 @@ impl FlightSqlService for FlightSqlServiceImpl { Ok(Response::new(Box::pin(stream))) } - async fn get_flight_info_statement( Review Comment: removing this code means it falls back to the default implementation (which also returns Not implemented) Seems like a nice change to me 👍 ########## datafusion-examples/examples/flight/flight_sql_server.rs: ########## @@ -337,234 +346,52 @@ impl FlightSqlService for FlightSqlServiceImpl { Ok(resp) } - async fn get_flight_info_catalogs( - &self, - _query: CommandGetCatalogs, - _request: Request<FlightDescriptor>, - ) -> Result<Response<FlightInfo>, Status> { - info!("get_flight_info_catalogs"); - Err(Status::unimplemented("Implement get_flight_info_catalogs")) - } - - async fn get_flight_info_schemas( - &self, - _query: CommandGetDbSchemas, - _request: Request<FlightDescriptor>, - ) -> Result<Response<FlightInfo>, Status> { - info!("get_flight_info_schemas"); - Err(Status::unimplemented("Implement get_flight_info_schemas")) - } - async fn get_flight_info_tables( Review Comment: 👍 ########## datafusion-examples/examples/flight/flight_sql_server.rs: ########## @@ -337,234 +346,52 @@ impl FlightSqlService for FlightSqlServiceImpl { Ok(resp) } - async fn get_flight_info_catalogs( - &self, - _query: CommandGetCatalogs, - _request: Request<FlightDescriptor>, - ) -> Result<Response<FlightInfo>, Status> { - info!("get_flight_info_catalogs"); - Err(Status::unimplemented("Implement get_flight_info_catalogs")) - } - - async fn get_flight_info_schemas( - &self, - _query: CommandGetDbSchemas, - _request: Request<FlightDescriptor>, - ) -> Result<Response<FlightInfo>, Status> { - info!("get_flight_info_schemas"); - Err(Status::unimplemented("Implement get_flight_info_schemas")) - } - async fn get_flight_info_tables( &self, _query: CommandGetTables, - _request: Request<FlightDescriptor>, + request: Request<FlightDescriptor>, ) -> Result<Response<FlightInfo>, Status> { info!("get_flight_info_tables"); - Err(Status::unimplemented("Implement get_flight_info_tables")) - } - - async fn get_flight_info_table_types( - &self, - _query: CommandGetTableTypes, - _request: Request<FlightDescriptor>, - ) -> Result<Response<FlightInfo>, Status> { - info!("get_flight_info_table_types"); - Err(Status::unimplemented( - "Implement get_flight_info_table_types", - )) - } - - async fn get_flight_info_sql_info( - &self, - _query: CommandGetSqlInfo, - _request: Request<FlightDescriptor>, - ) -> Result<Response<FlightInfo>, Status> { - info!("get_flight_info_sql_info"); - Err(Status::unimplemented("Implement CommandGetSqlInfo")) - } - - async fn get_flight_info_primary_keys( - &self, - _query: CommandGetPrimaryKeys, - _request: Request<FlightDescriptor>, - ) -> Result<Response<FlightInfo>, Status> { - info!("get_flight_info_primary_keys"); - Err(Status::unimplemented( - "Implement get_flight_info_primary_keys", - )) - } - - async fn get_flight_info_exported_keys( - &self, - _query: CommandGetExportedKeys, - _request: Request<FlightDescriptor>, - ) -> Result<Response<FlightInfo>, Status> { - info!("get_flight_info_exported_keys"); - Err(Status::unimplemented( - "Implement get_flight_info_exported_keys", - )) - } - - async fn get_flight_info_imported_keys( - &self, - _query: CommandGetImportedKeys, - _request: Request<FlightDescriptor>, - ) -> Result<Response<FlightInfo>, Status> { - info!("get_flight_info_imported_keys"); - Err(Status::unimplemented( - "Implement get_flight_info_imported_keys", - )) - } - - async fn get_flight_info_cross_reference( - &self, - _query: CommandGetCrossReference, - _request: Request<FlightDescriptor>, - ) -> Result<Response<FlightInfo>, Status> { - info!("get_flight_info_cross_reference"); - Err(Status::unimplemented( - "Implement get_flight_info_cross_reference", - )) - } - - async fn get_flight_info_xdbc_type_info( - &self, - _query: CommandGetXdbcTypeInfo, - _request: Request<FlightDescriptor>, - ) -> Result<Response<FlightInfo>, Status> { - info!("get_flight_info_xdbc_type_info"); - Err(Status::unimplemented( - "Implement get_flight_info_xdbc_type_info", - )) - } - - async fn do_get_statement( - &self, - _ticket: TicketStatementQuery, - _request: Request<Ticket>, - ) -> Result<Response<<Self as FlightService>::DoGetStream>, Status> { - info!("do_get_statement"); - Err(Status::unimplemented("Implement do_get_statement")) - } - - async fn do_get_prepared_statement( - &self, - _query: CommandPreparedStatementQuery, - _request: Request<Ticket>, - ) -> Result<Response<<Self as FlightService>::DoGetStream>, Status> { - info!("do_get_prepared_statement"); - Err(Status::unimplemented("Implement do_get_prepared_statement")) - } - - async fn do_get_catalogs( - &self, - _query: CommandGetCatalogs, - _request: Request<Ticket>, - ) -> Result<Response<<Self as FlightService>::DoGetStream>, Status> { - info!("do_get_catalogs"); - Err(Status::unimplemented("Implement do_get_catalogs")) - } - - async fn do_get_schemas( - &self, - _query: CommandGetDbSchemas, - _request: Request<Ticket>, - ) -> Result<Response<<Self as FlightService>::DoGetStream>, Status> { - info!("do_get_schemas"); - Err(Status::unimplemented("Implement do_get_schemas")) - } - - async fn do_get_tables( - &self, - _query: CommandGetTables, - _request: Request<Ticket>, - ) -> Result<Response<<Self as FlightService>::DoGetStream>, Status> { - info!("do_get_tables"); - Err(Status::unimplemented("Implement do_get_tables")) - } - - async fn do_get_table_types( - &self, - _query: CommandGetTableTypes, - _request: Request<Ticket>, - ) -> Result<Response<<Self as FlightService>::DoGetStream>, Status> { - info!("do_get_table_types"); - Err(Status::unimplemented("Implement do_get_table_types")) - } - - async fn do_get_sql_info( - &self, - _query: CommandGetSqlInfo, - _request: Request<Ticket>, - ) -> Result<Response<<Self as FlightService>::DoGetStream>, Status> { - info!("do_get_sql_info"); - Err(Status::unimplemented("Implement do_get_sql_info")) - } - - async fn do_get_primary_keys( - &self, - _query: CommandGetPrimaryKeys, - _request: Request<Ticket>, - ) -> Result<Response<<Self as FlightService>::DoGetStream>, Status> { - info!("do_get_primary_keys"); - Err(Status::unimplemented("Implement do_get_primary_keys")) - } - - async fn do_get_exported_keys( - &self, - _query: CommandGetExportedKeys, - _request: Request<Ticket>, - ) -> Result<Response<<Self as FlightService>::DoGetStream>, Status> { - info!("do_get_exported_keys"); - Err(Status::unimplemented("Implement do_get_exported_keys")) - } - - async fn do_get_imported_keys( - &self, - _query: CommandGetImportedKeys, - _request: Request<Ticket>, - ) -> Result<Response<<Self as FlightService>::DoGetStream>, Status> { - info!("do_get_imported_keys"); - Err(Status::unimplemented("Implement do_get_imported_keys")) - } + let ctx = self.get_ctx(&request)?; + let data = self.tables(ctx).await; + let schema = data.schema(); - async fn do_get_cross_reference( - &self, - _query: CommandGetCrossReference, - _request: Request<Ticket>, - ) -> Result<Response<<Self as FlightService>::DoGetStream>, Status> { - info!("do_get_cross_reference"); - Err(Status::unimplemented("Implement do_get_cross_reference")) - } + let uuid = Uuid::new_v4().hyphenated().to_string(); + self.results.insert(uuid.clone(), vec![data]); - async fn do_get_xdbc_type_info( - &self, - _query: CommandGetXdbcTypeInfo, - _request: Request<Ticket>, - ) -> Result<Response<<Self as FlightService>::DoGetStream>, Status> { - info!("do_get_xdbc_type_info"); - Err(Status::unimplemented("Implement do_get_xdbc_type_info")) - } + let fetch = FetchResults { handle: uuid }; + let buf = fetch.as_any().encode_to_vec().into(); + let ticket = Ticket { ticket: buf }; + let endpoint = FlightEndpoint { Review Comment: Nice! I think you can make this code simpler using `FlightInfo::new()` as shown on the examples in https://docs.rs/arrow-flight/latest/arrow_flight/struct.FlightInfo.html ```rust // Create a new FlightInfo let flight_info = FlightInfo::new() // Encode the Arrow schema .try_with_schema(&schema)) .expect("encoding failed") .with_endpoint( FlightEndpoint::new() .with_ticket(ticket) ) ) .with_descriptor(FlightDescriptor::new_cmd(Default::default())); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org