You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/08/24 08:15:57 UTC

[GitHub] [arrow-rs] skejserjensen commented on issue #2445: `SchemaResult` in IPC deviates from other implementations

skejserjensen commented on issue #2445:
URL: https://github.com/apache/arrow-rs/issues/2445#issuecomment-1225356558

   
   
   
   
   > You can change your server code to
   > 
   > ```
   > async fn get_schema(
   >     &self,
   >     _request: Request<FlightDescriptor>,
   > ) -> Result<Response<SchemaResult>, Status> {
   >     let tid = Field::new("tid", DataType::Int32, false);
   >     let timestamp = Field::new("timestamp", DataType::Timestamp(TimeUnit::Millisecond, None), false);
   >     let value = Field::new("value", DataType::Float32, false);
   >     let schema = Schema::new(vec![tid, timestamp, value]);
   > 
   >     let options = IpcWriteOptions::default();
   >     let schema_as_ipc = SchemaAsIpc::new(&schema, &options);
   >     // convert the schema as the ipc message
   >     let ipc_message : IpcMessage = IpcMessage::try_from(schema_as_ipc).unwrap();
   >     // wrap the `SchemaResult` using the ipc message bytes
   >     let schema_result: SchemaResult =  SchemaResult {
   >        schema: ipc_message.0,
   >     }
   > 
   >     Ok(Response::new(schema_result))
   > }
   > ```
   > 
   > @skejserjensen
   
   @liukun4515 and @zeroshade thank you for looking into this issue. 
   
   Based on @liukun4515's previous [comment](https://github.com/apache/arrow-rs/issues/2445#issuecomment-1223564637), I have also been looking into encoding [`Schema`](https://docs.rs/arrow/latest/arrow/datatypes/struct.Schema.html) as [`IpcMessage`](https://docs.rs/arrow-flight/latest/arrow_flight/struct.IpcMessage.html) using [`SchemaAsIpc`](https://docs.rs/arrow-flight/latest/arrow_flight/struct.SchemaAsIpc.html) and then returning the bytes from [`get_schema()`](https://docs.rs/arrow-flight/latest/arrow_flight/flight_service_server/trait.FlightService.html#tymethod.get_schema) as a  [`SchemaResult`](https://docs.rs/arrow-flight/latest/arrow_flight/struct.SchemaResult.html) to match the methods return type. I have successfully decoded these `SchemaResult`s containing the bytes from `IpcMessage`s using the Go, Java, Python, and Rust implementations of Apache Arrow Flight. 


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