You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/03/16 10:05:49 UTC

[GitHub] [arrow-rs] alamb opened a new issue, #3874: Make it easier to match FlightSQL messages

alamb opened a new issue, #3874:
URL: https://github.com/apache/arrow-rs/issues/3874

   **Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
   When implementing FlightSQL the do_get and get_flight_info gRPC methods are called for several of the message types. Thus those endpoints need to decode the incoming message and then do the appropriate action
   
   However, the current way the messages are decoded from `prost::Any` means the only way I have figured out how to check dynamically for each message type is an `if` chain like this
   
   ```rust
           } else if let Some(decoded_cmd) = Any::unpack::<CommandGetCatalogs>(&msg)? {
             // act
           } else if let Some(decoded_cmd) = Any::unpack::<CommandGetDbSchemas>(&msg)? {
             // act
           } else if let Some(decoded_cmd) = Any::unpack::<ActionCreatePreparedStatementRequest>(&msg)?
           {
             // ...
           }
   ```
   
   It would be great to have an enum so a rust `match` statement could be used
   
   
   
   **Describe alternatives you've considered**
   @stuartcarnie proposed the following in  https://github.com/influxdata/influxdb_iox/pull/7213/files#r1137963627:
   
    I created [a gist](https://gist.github.com/stuartcarnie/a121def085aaaf3f75ab5e592e4c4343#file-mod-rs-L230-L233) that extends [the sql crate](https://github.com/apache/arrow-rs/blob/9728c676b50b19c06643a23daba4aa4a1dc48055/arrow-flight/src/sql/mod.rs) in arrow-flight, that demonstrates an approach allowing us to remove all the `if Some(..)` to a single match:
   
   ```rust
   match Commands::unpack(&msg)? {
       Commands::CommandStatementQuery(cmd) => Ok(Self::CommandStatementQuery(cmd)),
       Commands::CommandPreparedStatementQuery(CommandPreparedStatementQuery { prepared_statement_handle }) => Ok(Self::CommandPreparedStatementQuery(preparedstatementhandle::try_decode(prepared_statement_handle)?)),
       // etc
   }
   ```
   
   I extended the `prost_message_ext` macro to create a `Commands` enum with all the messages passed to the macro. The `Commands` macro has a static function, `unpack`, that is capable of unpacking any of the registered messages.
   
   **Additional context**
   <!--
   Add any other context or screenshots about the feature request here.
   -->
   


-- 
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-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] stuartcarnie commented on issue #3874: Make it easier to match FlightSQL messages

Posted by "stuartcarnie (via GitHub)" <gi...@apache.org>.
stuartcarnie commented on issue #3874:
URL: https://github.com/apache/arrow-rs/issues/3874#issuecomment-1475442393

   @avantgardnerio and @alamb figured I'd clean up the Gist and open the PR:
   
   - https://github.com/apache/arrow-rs/pull/3887


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] avantgardnerio commented on issue #3874: Make it easier to match FlightSQL messages

Posted by "avantgardnerio (via GitHub)" <gi...@apache.org>.
avantgardnerio commented on issue #3874:
URL: https://github.com/apache/arrow-rs/issues/3874#issuecomment-1472132391

   This would be awesome to solve, thanks @stuartcarnie !


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] tustvold commented on issue #3874: Make it easier to match FlightSQL messages

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #3874:
URL: https://github.com/apache/arrow-rs/issues/3874#issuecomment-1500235618

   `label_issue.py` automatically added labels {'arrow'} from #3887


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] alamb closed issue #3874: Make it easier to match FlightSQL messages

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed issue #3874: Make it easier to match FlightSQL messages
URL: https://github.com/apache/arrow-rs/issues/3874


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] alamb commented on issue #3874: Make it easier to match FlightSQL messages

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #3874:
URL: https://github.com/apache/arrow-rs/issues/3874#issuecomment-1471654828

   cc @avantgardnerio 


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org