feat(nodejs): feature parity [6/N] - make public interface work with multiple arrow versions (#1392)

previously we didnt have great compatibility with other versions of
apache arrow. This should bridge that gap a bit.


depends on https://github.com/lancedb/lancedb/pull/1391
see actual diff here
https://github.com/universalmind303/lancedb/compare/query-filter...universalmind303:arrow-compatibility
This commit is contained in:
Cory Grinstead
2024-06-25 11:10:08 -05:00
committed by GitHub
parent a866b78a31
commit 79a1667753
8 changed files with 175 additions and 38 deletions

View File

@@ -17,6 +17,7 @@ import {
Data,
IntoVector,
Schema,
TableLike,
fromDataToBuffer,
fromTableToBuffer,
fromTableToStreamBuffer,
@@ -38,6 +39,8 @@ import {
Table as _NativeTable,
} from "./native";
import { Query, VectorQuery } from "./query";
import { sanitizeTable } from "./sanitize";
export { IndexConfig } from "./native";
/**
* Options for adding data to a table.
@@ -381,8 +384,7 @@ export abstract class Table {
abstract indexStats(name: string): Promise<IndexStatistics | undefined>;
static async parseTableData(
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
data: Record<string, unknown>[] | ArrowTable<any>,
data: Record<string, unknown>[] | TableLike,
options?: Partial<CreateTableOptions>,
streaming = false,
) {
@@ -395,9 +397,9 @@ export abstract class Table {
let table: ArrowTable;
if (isArrowTable(data)) {
table = data;
table = sanitizeTable(data);
} else {
table = makeArrowTable(data, options);
table = makeArrowTable(data as Record<string, unknown>[], options);
}
if (streaming) {
const buf = await fromTableToStreamBuffer(