diff --git a/nodejs/__test__/table.test.ts b/nodejs/__test__/table.test.ts index 9d191d7d..f6e168b9 100644 --- a/nodejs/__test__/table.test.ts +++ b/nodejs/__test__/table.test.ts @@ -21,6 +21,7 @@ import * as arrowOld from "apache-arrow-old"; import { Table, connect } from "../lancedb"; import { + Table as ArrowTable, Field, FixedSizeList, Float, @@ -94,6 +95,11 @@ describe.each([arrow, arrowOld])("Given a table", (arrow: any) => { expect(await table.countRows("id == 7")).toBe(1); expect(await table.countRows("id == 10")).toBe(1); }); + + it("should return the table as an instance of an arrow table", async () => { + const arrowTbl = await table.toArrow(); + expect(arrowTbl).toBeInstanceOf(ArrowTable); + }); }); describe("When creating an index", () => { diff --git a/nodejs/lancedb/table.ts b/nodejs/lancedb/table.ts index 7e40669c..eda6c6da 100644 --- a/nodejs/lancedb/table.ts +++ b/nodejs/lancedb/table.ts @@ -11,8 +11,13 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - -import { Data, Schema, fromDataToBuffer, tableFromIPC } from "./arrow"; +import { + Table as ArrowTable, + Data, + Schema, + fromDataToBuffer, + tableFromIPC, +} from "./arrow"; import { getRegistry } from "./embedding/registry"; import { IndexOptions } from "./indices"; @@ -24,8 +29,8 @@ import { Table as _NativeTable, } from "./native"; import { Query, VectorQuery } from "./query"; - export { IndexConfig } from "./native"; + /** * Options for adding data to a table. */ @@ -423,4 +428,9 @@ export class Table { async listIndices(): Promise { return await this.inner.listIndices(); } + + /** Return the table as an arrow table */ + async toArrow(): Promise { + return await this.query().toArrow(); + } }