You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current JS documentation is not clear on how to read & manipulate the data from Apache Arrow JS
JS version of Apache Arrow is used in JS environment (DuckDB Wasm, ObservableHQ, Arquero)
and people are asking on how to properly read the data, but there is no clear answer duckdb/duckdb-wasm#1418
bluehat974
changed the title
Improve JS documentation on how to read/deserialize arrow data
[JS] Improve JS documentation on how to read/deserialize arrow data
Sep 25, 2023
100% agree on points mentioned above. I'm also curious if there is built-in Arrow functionality to handle casting to native Javascript types.
My workaround:
import{Table}from'apache-arrow'import{mapValues}from'lodash'exportconstarrowTableToRecords=(arrow: Table): Record<string,any>[]=>{// this does not handle BigInts, can't override prototype because it refers to private symbol// const after = arrow.toArray().map((row) => row.toJSON())returnarrow.toArray().map((obj: object)=>{returnmapValues(obj,(v: any)=>{if(typeofv==='bigint'){if(v<Number.MIN_SAFE_INTEGER||v>Number.MAX_SAFE_INTEGER){thrownewTypeError(`${v} is not safe to convert to a number.`)}returnNumber(v)}returnv})})}
I'm thinking about adding a way to tell arrow that you want data to be returned in more compatible types (e.g. arrays of numbers instead of bigints, numbers instead of decimal objects). It's not there yet but I think toArray is often not generating what people want.
Describe the enhancement requested
cc @domoritz
Current JS documentation is not clear on how to read & manipulate the data from Apache Arrow JS
JS version of Apache Arrow is used in JS environment (DuckDB Wasm, ObservableHQ, Arquero)
and people are asking on how to properly read the data, but there is no clear answer
duckdb/duckdb-wasm#1418
There is some documentation to read arrow data or deserialize to JSON
https://duckdb.org/docs/api/wasm/query.html#arrow-table-to-json
https://observablehq.com/@theneuralbit/using-apache-arrow-js-with-large-datasets
but this examples should be unified to the original Apache Arrow JS documentation
https://github.com/apache/arrow/blob/main/js/README.md
Some ideas of code example to provide to the documentation:
Component(s)
Documentation, JavaScript
The text was updated successfully, but these errors were encountered: