feat(node): support table.schema for LocalTable (#789)

Close #773 

we pass an empty table over IPC so we don't need to manually deal with
serde. Then we just return the schema attribute from the empty table.

---------

Co-authored-by: albertlockett <albert.lockett@gmail.com>
This commit is contained in:
Chang She
2024-01-08 21:12:48 -08:00
committed by Weston Pace
parent 4c8690549a
commit 175ad9223b
7 changed files with 98 additions and 25 deletions

View File

@@ -498,6 +498,27 @@ describe('LanceDB client', function () {
assert.equal(results.length, 2)
})
})
describe('when inspecting the schema', function () {
it('should return the schema', async function () {
const uri = await createTestDB()
const db = await lancedb.connect(uri)
// the fsl inner field must be named 'item' and be nullable
const expectedSchema = new Schema(
[
new Field('id', new Int32()),
new Field('vector', new FixedSizeList(128, new Field('item', new Float32(), true))),
new Field('s', new Utf8())
]
)
const table = await db.createTable({
name: 'some_table',
schema: expectedSchema
})
const schema = await table.schema
assert.deepEqual(expectedSchema, schema)
})
})
})
describe('Remote LanceDB client', function () {