You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "bmschmidt (via GitHub)" <gi...@apache.org> on 2023/08/26 15:37:35 UTC
[GitHub] [arrow] bmschmidt opened a new issue, #37401: [JS] Deserializing schema from bytes
bmschmidt opened a new issue, #37401:
URL: https://github.com/apache/arrow/issues/37401
### Describe the usage question you have. Please include as many useful details as possible.
In the javascript package, how could one deserialize an Arrow schema from raw bytes?
In pyarrow, for example, I can do this:
```python
import pyarrow as pa
import io
import base64
pa.ipc.read_schema(io.BytesIO(base64.b64decode(b'/////3AAAAAQAAAAAAAKAAwABgAFAAgACgAAAAABBAAMAAAACAAIAAAABAAIAAAABAAAAAEAAAAUAAAAEAAUAAgABgAHAAwAAAAQABAAAAAAAAEDEAAAABgAAAAEAAAAAAAAAAEAAAB4AAYACAAGAAYAAAAAAAEA')))
```
But I'm struggling to find any way to do the equivalent in javascript, even after reading the code a bit.
The below (and various permutations involving ArrayBuffers, ByteBuffer objects in flatbuffers, etc.) all fail.
```javascript
import { Message, Schema, tableFromIPC } from 'apache-arrow'
const sch = `/////3AAAAAQAAAAAAAKAAwABgAFAAgACgAAAAABBAAMAAAACAAIAAAABAAIAAAABAAAAAEAAAAUAAAAEAAUAAgABgAHAAwAAAAQABAAAAAAAAEDEAAAABgAAAAEAAAAAAAAAAEAAAB4AAYACAAGAAYAAAAAAAEA`
const decoded = atob(sch);
const bytes = Uint8Array.from(decoded, c => c.charCodeAt(0))
console.log(Schema.decode(bytes))
```
I can deserialize a full table with tableFromIPC, but there are times that I would like to work with a schema without any attached data.
Thanks for any help!
### Component(s)
JavaScript
--
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: issues-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] bmschmidt commented on issue #37401: [JS] Deserializing schema from bytes
Posted by "bmschmidt (via GitHub)" <gi...@apache.org>.
bmschmidt commented on issue #37401:
URL: https://github.com/apache/arrow/issues/37401#issuecomment-1694555001
Update: I realized that it's possible to grab the schema off the table generated using the `tableFromIPC` function even without passing an associated data.
```js
import { tableFromIPC } from 'apache-arrow'
const sch = `/////3AAAAAQAAAAAAAKAAwABgAFAAgACgAAAAABBAAMAAAACAAIAAAABAAIAAAABAAAAAEAAAAUAAAAEAAUAAgABgAHAAwAAAAQABAAAAAAAAEDEAAAABgAAAAEAAAAAAAAAAEAAAB4AAYACAAGAAYAAAAAAAEA`
const decoded = atob(sch);
const bytes = Uint8Array.from(decoded, c => c.charCodeAt(0))
console.log(tableFromIPC(bytes).schema)
```
--
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] bmschmidt closed issue #37401: [JS] Deserializing schema from bytes
Posted by "bmschmidt (via GitHub)" <gi...@apache.org>.
bmschmidt closed issue #37401: [JS] Deserializing schema from bytes
URL: https://github.com/apache/arrow/issues/37401
--
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: issues-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org