Repository navigation
Conversation
vectorFromArray and tableFromArrays treated typed array elements as plain objects, so an array of Uint8Array became a Struct with one Float64 field per byte. Ragged lengths were padded with nulls, and the static type resolved to never. Infer Uint8Array (and Buffer) elements as Binary and other typed arrays as List of their element type, keeping the static types in step. Mixed typed array kinds and DataView now throw like other ambiguous inputs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Infers arrays of typed arrays as proper Arrow types, so
vectorFromArray([uint8Array, ...])produces aBinaryvector instead of a struct with oneFloat64field per byte.The problem
Type inference treated typed arrays as plain objects and built a struct from their index keys. An array of 16-byte
Uint8Arrayvalues becameStruct<{0: Float64, ..., 15: Float64}>instead ofBinary. The output was also lossy: values of different lengths were padded with nulls to the longest one, and the static type resolved tonever.Behavior change
This changes the inferred type for these inputs, but it's a bug fix: the old output didn't preserve the input values and didn't match its own static type. Code that needs a specific type can still pass one explicitly to
vectorFromArray.Changes
vectorFromArrayinfersUint8Array(and NodeBuffer) elements asBinary, and other typed arrays asListof their element type (e.g.Int32Array→List<Int32>)tableFromArraysandtableFromJSONpick this up for columns and struct fields, sotableFromArrays({ values: [[bytes, bytes]] })givesList<Binary>JavaScriptArrayDataTyperesolves to the same types at compile time instead ofneverDataViewelements throw the existing "explicit type declaration expected" errorTest Plan
npx jest -c jestconfigs/jest.src.config.js test/unitnpx eslint src/factories.ts src/interfaces.ts test/unit/vector/vector-tests.tsUint8Array,Buffer,Int32Array,Uint8ClampedArray, andBigInt64Arraywithtsc