GitHub user DadiBit added a comment to the discussion: Better type safety schemas
> Note: Javascript objects [do not guarantee insertion > order](https://stackoverflow.com/a/23202095/9373031) IF the key type differs > (I see both strings and numbers are allowed in the same schema - like a field > named `1` and one named `"name"`) Example of writer that uses both strings and numbers as keys (Symbols are not supported, so we don't even need to work with them): ```typescript // write.js import { tableToIPC, Schema, Field, Uint8, Float32, Table, makeData, vectorFromArray } from 'apache-arrow'; import * as fs from 'fs'; const schema = new Schema([ new Field('precipitations', new Float32()), new Field('0', new Uint8()), ]); const table = new Table(schema, { age: makeData({ type: new Float32(), length: 3, data: vectorFromArray([1, 2, 3.14]) }), 0: makeData({ type: new Uint8(), length: 3, data: vectorFromArray([7, 8, 9]) }), }); fs.writeFileSync('simple.arrow', tableToIPC(table, 'file')); ``` And then, if we read we can see column order retention: ```typescript // read.js import { tableFromIPC } from 'apache-arrow'; import * as fs from 'fs'; const table = tableFromIPC(fs.readFileSync('simple.arrow')); console.log(table.schema.fields); // Now you should see that the field '0' comes after 'precipitations', "not standard", but expected behavior IMHO ``` With that said, if we look into the friendlier `makeTable` & Co. the result is that objects are used from the get-go. So field order isn't crucial, from my understanding, however the underlying structure should probably respect it. --- See PR #233 GitHub link: https://github.com/apache/arrow-js/discussions/232#discussioncomment-14063251 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected]
