feat(js): add helper function to create Arrow Table with schema (#838)

Support to make Apache Arrow Table from an array of javascript Records,
with optionally provided Schema.
This commit is contained in:
Lei Xu
2024-01-22 11:49:44 -08:00
committed by Weston Pace
parent b699b5c42b
commit d8befeeea2
4 changed files with 315 additions and 20 deletions

View File

@@ -41,12 +41,13 @@ const {
tableListIndices,
tableIndexStats,
tableSchema
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-var-requires
} = require('../native.js')
export { Query }
export type { EmbeddingFunction }
export { OpenAIEmbeddingFunction } from './embedding/openai'
export { makeArrowTable, type MakeArrowTableOptions } from './arrow'
const defaultAwsRegion = 'us-west-2'
@@ -859,7 +860,10 @@ export class LocalTable<T = number[]> implements Table<T> {
private checkElectron (): boolean {
try {
// eslint-disable-next-line no-prototype-builtins
return (process?.versions?.hasOwnProperty('electron') || navigator?.userAgent?.toLowerCase()?.includes(' electron'))
return (
Object.prototype.hasOwnProperty.call(process?.versions, 'electron') ||
navigator?.userAgent?.toLowerCase()?.includes(' electron')
)
} catch (e) {
return false
}