roeap commented on code in PR #4296:
URL: https://github.com/apache/arrow-rs/pull/4296#discussion_r1211933429


##########
arrow-flight/examples/flight_sql_server.rs:
##########
@@ -396,23 +477,113 @@ impl FlightSqlService for FlightSqlServiceImpl {
         _query: CommandGetCatalogs,
         _request: Request<Ticket>,
     ) -> Result<Response<<Self as FlightService>::DoGetStream>, Status> {
-        Err(Status::unimplemented("do_get_catalogs not implemented"))
+        let catalog_names = TABLES
+            .iter()
+            .map(|full_name| 
full_name.split('.').collect::<Vec<_>>()[0].to_string())
+            .collect::<HashSet<_>>();
+        let batch = get_catalogs_batch(catalog_names.into_iter().collect());
+        let stream = FlightDataEncoderBuilder::new()
+            .with_schema(Arc::new(get_catalogs_schema().clone()))
+            .build(futures::stream::once(async { batch }))
+            .map_err(Status::from);
+        Ok(Response::new(Box::pin(stream)))
     }
 
     async fn do_get_schemas(
         &self,
-        _query: CommandGetDbSchemas,
+        query: CommandGetDbSchemas,
         _request: Request<Ticket>,
     ) -> Result<Response<<Self as FlightService>::DoGetStream>, Status> {
-        Err(Status::unimplemented("do_get_schemas not implemented"))
+        let schemas = TABLES
+            .iter()
+            .map(|full_name| {
+                let parts = full_name.split('.').collect::<Vec<_>>();
+                (parts[0].to_string(), parts[1].to_string())
+            })
+            .collect::<HashSet<_>>();
+
+        let mut builder = 
GetSchemasBuilder::new(query.db_schema_filter_pattern);
+        if let Some(catalog) = query.catalog {

Review Comment:
   @alamb, since we are then using all the fields on the command object, should 
we just convert one into the other?
   
   Someting like given `query` is `CommandGetDbSchemas`.
   
   ```rs
   let mut builder: GetSchemasBuilder = query.builder();
   ```
   
   implementing from, with maybe the downside, that you would always actually 
have to case the type..
   
   ```rs
   let mut builder: GetSchemasBuilder = query.into();
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to