kevinschaich commented on issue #37856:
URL: https://github.com/apache/arrow/issues/37856#issuecomment-2083316617

   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:
   
   ```typescript
   import { Table } from 'apache-arrow'
   import { mapValues } from 'lodash'
   
   export const arrowTableToRecords = (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())
   
       return arrow.toArray().map((obj: object) => {
           return mapValues(obj, (v: any) => {
               if (typeof v === 'bigint') {
                   if (v < Number.MIN_SAFE_INTEGER || v > 
Number.MAX_SAFE_INTEGER) {
                       throw new TypeError(`${v} is not safe to convert to a 
number.`)
                   }
                   return Number(v)
               }
               return v
           })
       })
   }
   ```
   
   LMK if others have a better way to do this.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to