Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,16 @@ interface FlightRecord {
const flights = (await result.collectToObjects()) as FlightRecord[];
console.log(flights);
```

## Arrow Integration

The client can return query results as an Arrow table. Transferring Arrow data across JavaScript API boundaries
is tricky because the Arrow package uses a number of `instanceof` checks to determine the type of objects. For
these to work correctly, the Arrow package your application is using must be the exact same version
used by this package. In addition, the Arrow package must be loaded in the same context as this package.
This process can often fail in the presence of bundlers like Webpack or Rollup.

If you are using a bundler, it is recommended to use `collectToObjects` instead.

If you would like to improve this situation I encourage you to make a stab at
[this Github issue](https://github.com/lancedb/flight-sql-js-client/issues/11).
9 changes: 9 additions & 0 deletions integration_test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,13 @@ describe("with a client we can", () => {
expect(result[0].l_orderkey).toBeGreaterThan(0);
expect(result[1].l_returnflag.length).toBeGreaterThan(0);
});

test("return query results as an Arrow table", async () => {
const queryResult = await client.query("SELECT * FROM lineitem LIMIT 10");
const result = await queryResult.collectToArrow();
expect(result).toBeDefined();
expect(result.length).toBe(1);
const batch = result[0];
expect(batch.numRows).toBe(10);
});
});
128 changes: 52 additions & 76 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"@grpc/grpc-js": "^1.12.4",
"@grpc/proto-loader": "^0.7.13",
"apache-arrow": "^18.1.0",
"apache-arrow": "^21.1.0",
"iter-ops": "^3.5.0",
"protobufjs": "^7.4.0"
}
Expand Down