fix(node): validate deferred list siblings

This commit is contained in:
Gatefixer
2026-08-06 09:06:38 +00:00
parent b2e60181a1
commit 75f61cb269
2 changed files with 20 additions and 0 deletions
+13
View File
@@ -527,6 +527,19 @@ describe.each([arrow15, arrow16, arrow17, arrow18])(
).toEqual(nestedRecords.map((record) => record.items));
});
it("will reject incompatible deferred evidence within a list", function () {
for (const items of [
[[], 1],
[1, []],
[[null], 1],
[1, [null]],
]) {
expect(() => makeArrowTable([{ items }])).toThrow(
"Failed to infer data type for field items at row 0.",
);
}
});
it("will reject empty fixed-size lists", function () {
expect(() =>
makeArrowTable([{ vector: [1, 2, 3] }, { vector: [] }]),
+7
View File
@@ -857,12 +857,14 @@ function inferType(
);
}
let valueType: DataType | undefined;
const deferredItems: unknown[] = [];
for (const item of value) {
const itemType = inferType(item, path, opts);
if (itemType === undefined) {
if (!hasOnlyNoTypeEvidence(item)) {
return undefined;
}
deferredItems.push(item);
} else if (valueType === undefined) {
valueType = itemType;
} else if (!compareInferredTypes(valueType, itemType)) {
@@ -872,6 +874,11 @@ function inferType(
if (valueType === undefined) {
return undefined;
}
for (const item of deferredItems) {
if (!noTypeEvidenceMatchesType(item, valueType)) {
return undefined;
}
}
// Try to automatically detect embedding columns.
if (nameSuggestsVectorColumn(path[path.length - 1])) {
// Check if value is a Uint8Array for integer vector type determination