Commits


Brian Hulette authored and Wes McKinney committed 8e2248273a3
ARROW-2767: [JS] Add generic to Table for column names Adds a generic to `Table`, `StructVector,` and `Struct`, which allows a user to define their schema at compile time and get some type checking. Includes changes from #2197 For example: ```js import { readFileSync } from 'fs'; import { Table } from 'apache-arrow'; import { Dictionary, Float, Utf8, Int } from 'apache-arrow/type'; type Record = { lat: Float, lng: Float, altitude: Int, callsign: Dictionary<Utf8>, } const table = Table.from<Record>(readFileSync('./test.arrow')); function test_number(value: number) { return value < 1000; } const row = table.get(0)!; // error TS2345: Argument of type 'string' is not assignable to parameter of // type 'number'. test_number(row.callsign); test_number(table.getColumn('callsign')!.get(0)!); // error TS2339: Property 'foo' does not exist on type 'StructValue<Record> // & View<any>'. row.foo // error TS2345: Argument of type '"foo"' is not assignable to parameter of // type '"lat" | "lng" | "altitude" | "callsign"'. table.getColumn('foo') // No error test_number(row.altitude); test_number(table.getColumn('altitude')!.get(0)!); ``` Author: Brian Hulette <hulettbh@gmail.com> Closes #2256 from TheNeuralBit/table-types and squashes the following commits: 67dab8ab5 <Brian Hulette> Add generic to RecordBatch.from 9fb7defc1 <Brian Hulette> Use Struct for Table accessors e6d70131d <Brian Hulette> Remove unnecessary import/exports, thanks to TS 2.9 29c89e6bd <Brian Hulette> Add generic to DataFrame, static methods b6fe0d418 <Brian Hulette> Add generic to Table to enable compile-time checks on column names/types