Skip to content

Conversation

@TheMrCam
Copy link
Contributor

@TheMrCam TheMrCam commented Aug 27, 2025

Overview

Should resolve #129 by setting the byteWidth correctly (according to the advice in the issue) to 8.

Details

I realized that getTimeByteWidth was only being used by Timestamp and Duration, so I ended up just removing it and hardcoding the byteWidth.

I also wasn't able to successfully run the tests, but I did successfully run yarn build (with ArrayBufferLike warnings). I can run the tests if necessary, but I may need a little guidance on the rust-arrow-ffi setup.

I realized that the only places calling getTimeByteWidth were the
Timestamp and Duration blocks, which are the two blocks that always use
BigInt64Array. So rather than keep the function call for those two
scenarios, which should (if I understand correctly) always return 8
anyway, I just dropped in the constant.
@kylebarron
Copy link
Owner

It would be great to have tests specifically for the time, duration, and timestamp array types.

I think you just need to update the version of wasm-bindgen for the tests to run.

@kylebarron
Copy link
Owner

It looks like #131 at least gets past that error point

@kylebarron
Copy link
Owner

You can try merging in main and see if that fixes your tests

I wasn't sure if I should commit these or not, but this is what I had to
do in onder to get yarn test to run locally.
@TheMrCam
Copy link
Contributor Author

I merged in main, and went through and got yarn test working locally. I did add wasm-pack to rust-arrow-ffi's devDependencies, so I pushed that and the yarn.lock changes, but I can revert if those updates are unnecessary or unwanted.

I see the yarn.lock changes broke the CI while I was writing this. Should I force push a reset without that latest commit?

@kylebarron
Copy link
Owner

I think adding wasm-pack to dev dependencies is fine.

Is there a reason why yarn install locally wouldn't create a yarn.lock that isn't consistent with the version in CI? Do we need to do something to match the yarn versions?

@TheMrCam
Copy link
Contributor Author

I assume the yarn.lock discrepancy is due to my yarn version: 4.9.4. I normally use npm, so I had to install yarn to use the yarn.lock rather than create a package-lock.json. It looks like the rust-arrow-ffi lockfile version went from 6 to 8, so I'd guess that one was generated with an older yarn version. Interestingly, the top level yarn.lock was already version 8.

I can figure out which yarn version corresponds to a version 6 yarn.lock and re-run yarn install within rust-arrow-ffi. Unless the lockfile version change is because there were no dependencies before, but I added wasm-pack? I'll look into that too.

@kylebarron
Copy link
Owner

You can bump the version of yarn here:

"yarn": "4.0.2"

which should get picked up as the version of yarn used by CI:

- name: Set up Volta
uses: volta-cli/action@v4

Per advice on PR, bumping the CI yarn version to match my local version,
4.9.4
Found the prettier command in the package.json scripts so I ran it :)
@kylebarron
Copy link
Owner

Would you be able to try uncommenting this test?

// // This also looks to be failing; probably an issue with the byte width?
// test.skip("timestamp", (t) => {
// let columnIndex = TEST_TABLE.schema.fields.findIndex(
// (field) => field.name == "timestamp"
// );
// const originalField = TEST_TABLE.schema.fields[columnIndex];
// const originalVector = TEST_TABLE.getChildAt(columnIndex)!;
// const fieldPtr = FFI_TABLE.schemaAddr(columnIndex);
// const field = parseField(WASM_MEMORY.buffer, fieldPtr);
// expect(field.name).toStrictEqual(originalField.name);
// expect(field.typeId).toStrictEqual(originalField.typeId);
// expect(field.nullable).toStrictEqual(originalField.nullable);
// const arrayPtr = FFI_TABLE.arrayAddr(0, columnIndex);
// const wasmVector = parseVector(WASM_MEMORY.buffer, arrayPtr, field.type);
// console.log(wasmVector.toJSON());
// for (let i = 0; i < 3; i++) {
// console.log(originalVector.get(i));
// console.log(wasmVector.get(i));
// expect(originalVector.get(i), wasmVector.get(i));
// }
// });

It should be able to load this timestamp array defined in python:

def timestamp_array() -> pa.Array:
arr = pa.TimestampArray.from_pandas(
[datetime.now(), datetime.now(), datetime.now()],
type=pa.timestamp("s", tz="America/New_York"),
)
assert isinstance(arr, pa.TimestampArray)
assert arr.type.unit == "s"
assert arr.type.tz == "America/New_York"
return arr

Per PR request, uncommented the "timestamp" test in ffi.test.ts and then
recommented the console.log calls (as I assume they're unwanted with a
succeeding test). Also "fixed" the test by replacing the word "test"
with "it", which seemed more in-line with the rest of the file.
@kylebarron
Copy link
Owner

Awesome, thanks!

@kylebarron kylebarron merged commit 120ab23 into kylebarron:main Aug 28, 2025
1 check passed
@TheMrCam TheMrCam deleted the fix-timestamp-datatype branch August 28, 2025 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FFI] - RangeError: byte length of BigInt64Array should be a multiple of 8

2 participants