You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "wjones127 (via GitHub)" <gi...@apache.org> on 2024/09/18 21:53:55 UTC
[I] [IPC] Expose `schema` on `StreamDecoder` [arrow-rs]
wjones127 opened a new issue, #6420:
URL: https://github.com/apache/arrow-rs/issues/6420
**Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
There is a nice example in the `StreamDecoder::decode` docs from reading from a stream:
> ```rust
> fn print_stream<I>(src: impl Iterator<Item = Buffer>) -> Result<(), ArrowError> {
> let mut decoder = StreamDecoder::new();
> for mut x in src {
> while !x.is_empty() {
> if let Some(x) = decoder.decode(&mut x)? {
> println!("{x:?}");
> }
> }
> }
> decoder.finish().unwrap();
> Ok(())
> }
> ```
https://docs.rs/arrow-ipc/latest/arrow_ipc/reader/struct.StreamDecoder.html#method.decode
**However, it doesn't show how to get the schema.** This would be useful if someone wanted to construct a `RecordBatchReader` or `SendableRecordBatchStream` from a stream of `Bytes` / `Buffer`. And it would be particularly helpful in cases where there were zero batches but we still wanted to get the schema.
**Describe the solution you'd like**
Minimally, it would be nice to do this:
```rust
impl StreamDecoder {
/// Return the schema, if decoded yet. Returns `None` if the schema message
/// has yet to be decoded.
fn schema(&self) -> Option<SchemaRef> { ... }
}
```
But it might also be nice to parallel the decode method:
```rust
impl StreamDecoder {
/// Return the schema, if decoded yet. Returns `None` if the schema message
/// has yet to be decoded.
fn decode_schema(&mut self, buffer: &mut Buffer) -> Option<SchemaRef> { ... }
}
```
**Describe alternatives you've considered**
I asked in Slack if there were other straight forward ways, but didn't see anything easy from the suggestions. https://the-asf.slack.com/archives/C01QUFS30TD/p1726636373388569
**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
Re: [I] [IPC] Expose `schema` on `StreamDecoder` [arrow-rs]
Posted by "fsdvh (via GitHub)" <gi...@apache.org>.
fsdvh commented on issue #6420:
URL: https://github.com/apache/arrow-rs/issues/6420#issuecomment-2459832778
Also interested in this one
--
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
Re: [I] [IPC] Expose `schema` on `StreamDecoder` [arrow-rs]
Posted by "crepererum (via GitHub)" <gi...@apache.org>.
crepererum closed issue #6420: [IPC] Expose `schema` on `StreamDecoder`
URL: https://github.com/apache/arrow-rs/issues/6420
--
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