stuartcarnie commented on code in PR #3887:
URL: https://github.com/apache/arrow-rs/pull/3887#discussion_r1144075851


##########
arrow-flight/src/sql/server.rs:
##########
@@ -315,90 +315,57 @@ where
         let message =
             
Any::decode(&*request.get_ref().cmd).map_err(decode_error_to_status)?;
 
-        if message.is::<CommandStatementQuery>() {
-            let token = message
-                .unpack()
-                .map_err(arrow_error_to_status)?
-                .expect("unreachable");
-            return self.get_flight_info_statement(token, request).await;
-        }
-        if message.is::<CommandPreparedStatementQuery>() {
-            let handle = message
-                .unpack()
-                .map_err(arrow_error_to_status)?
-                .expect("unreachable");
-            return self
-                .get_flight_info_prepared_statement(handle, request)
-                .await;
-        }
-        if message.is::<CommandGetCatalogs>() {
-            let token = message
-                .unpack()
-                .map_err(arrow_error_to_status)?
-                .expect("unreachable");
-            return self.get_flight_info_catalogs(token, request).await;
-        }
-        if message.is::<CommandGetDbSchemas>() {
-            let token = message
-                .unpack()
-                .map_err(arrow_error_to_status)?
-                .expect("unreachable");
-            return self.get_flight_info_schemas(token, request).await;
-        }
-        if message.is::<CommandGetTables>() {
-            let token = message
-                .unpack()
-                .map_err(arrow_error_to_status)?
-                .expect("unreachable");
-            return self.get_flight_info_tables(token, request).await;
-        }
-        if message.is::<CommandGetTableTypes>() {
-            let token = message
-                .unpack()
-                .map_err(arrow_error_to_status)?
-                .expect("unreachable");
-            return self.get_flight_info_table_types(token, request).await;
+        match Command::try_from(message).map_err(arrow_error_to_status)? {
+            Command::CommandStatementQuery(token) => {
+                self.get_flight_info_statement(token, request).await
+            }
+            Command::CommandPreparedStatementQuery(handle) => {
+                self.get_flight_info_prepared_statement(handle, request)
+                    .await
+            }
+            Command::CommandGetCatalogs(token) => {
+                self.get_flight_info_catalogs(token, request).await
+            }
+            Command::CommandGetDbSchemas(token) => {
+                return self.get_flight_info_schemas(token, request).await
+            }
+            Command::CommandGetTables(token) => {
+                self.get_flight_info_tables(token, request).await
+            }
+            Command::CommandGetTableTypes(token) => {
+                self.get_flight_info_table_types(token, request).await
+            }
+            Command::CommandGetSqlInfo(token) => {
+                self.get_flight_info_sql_info(token, request).await
+            }
+            Command::CommandGetPrimaryKeys(token) => {
+                self.get_flight_info_primary_keys(token, request).await
+            }
+            Command::CommandGetExportedKeys(token) => {
+                self.get_flight_info_exported_keys(token, request).await
+            }
+            Command::CommandGetImportedKeys(token) => {
+                self.get_flight_info_imported_keys(token, request).await
+            }
+            Command::CommandGetCrossReference(token) => {
+                self.get_flight_info_cross_reference(token, request).await
+            }
+            Command::ActionClosePreparedStatementRequest(_)
+            | Command::ActionCreatePreparedStatementRequest(_)
+            | Command::CommandPreparedStatementUpdate(_)
+            | Command::CommandStatementUpdate(_)
+            | Command::DoPutUpdateResult(_)
+            | Command::TicketStatementQuery(_)
+            | Command::ActionCreatePreparedStatementResult(_) => {
+                Err(Status::unimplemented(format!(
+                    "get_flight_info: The defined request is invalid: {}",
+                    command.type_url()
+                )))
+            }
+            Command::Unknown(Any { ref type_url, .. }) => 
Err(Status::invalid_argument(
+                format!("get_flight_info: The defined request is invalid: 
{type_url}"),
+            )),

Review Comment:
   Disregard, as I've combined remaining cases.



-- 
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