Upload a table
Start the local Flight server. Create a table with tableFromArrays() and upload it using doPut() with the descriptor demo/uploaded. The server returns the number of rows written in its application metadata.
upload-table.ts
import { FlightClient, pathDescriptor } from 'arrow-flight-client';
import { tableFromArrays } from 'apache-arrow';
async function main() {
const client = new FlightClient('127.0.0.1:8815');
const table = tableFromArrays({
id: [4, 5, 6],
name: ['Dave', 'Eve', 'Frank']
});
try {
for await (const result of client.doPut(
pathDescriptor('demo', 'uploaded'),
table
)) {
if (result.appMetadata) {
console.log('Rows written:', Buffer.from(result.appMetadata).toString('utf8'));
}
}
console.log('Table uploaded');
}
finally {
await client.close();
}
}
await main();
The demo/uploaded table appears in the resource list. To send multiple batches, pass a sequence of RecordBatch objects to doPut(). The caller determines each batch size.