diff --git a/tests/ffi.test.ts b/tests/ffi.test.ts index a48668e..ef74653 100644 --- a/tests/ffi.test.ts +++ b/tests/ffi.test.ts @@ -661,6 +661,40 @@ describe("duration", (t) => { it("copy=true", () => test(true)); }); + +describe("interval", (t) => { + function test(copy: boolean) { + let columnIndex = TEST_TABLE.schema.fields.findIndex( + (field) => field.name == "interval" + ); + + const originalField = TEST_TABLE.schema.fields[columnIndex]; + // declare it's not null + const originalVector = TEST_TABLE.getChildAt(columnIndex) as arrow.Vector; + 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, + copy + ); + + for (let i = 0; i < 3; i++) { + expect(originalVector.get(i), wasmVector.get(i)); + } + } + + it("copy=false", () => test(false)); + it("copy=true", () => test(true)); +}); + describe("nullable int", (t) => { function test(copy: boolean) { let columnIndex = TEST_TABLE.schema.fields.findIndex( diff --git a/tests/pyarrow_generate_data.py b/tests/pyarrow_generate_data.py index 60f7d3c..4c08f27 100644 --- a/tests/pyarrow_generate_data.py +++ b/tests/pyarrow_generate_data.py @@ -1,4 +1,4 @@ -from datetime import date, datetime +from datetime import date, datetime, timedelta from decimal import Decimal import numpy as np @@ -130,6 +130,16 @@ def duration_array() -> pa.Array: return arr +def interval_array() -> pa.Array: + val = timedelta( + days=1, seconds=1, microseconds=1, milliseconds=1, minutes=1, hours=1, weeks=1 + ) + arr = pa.array([val, val, val], pa.month_day_nano_interval()) + + assert isinstance(arr, pa.MonthDayNanoIntervalArray) + return arr + + def nullable_int() -> pa.Array: # True means null mask = [True, False, True] @@ -243,10 +253,10 @@ def table() -> pa.Table: "sparse_union": sparse_union_array(), "dense_union": dense_union_array(), "duration": duration_array(), + "interval": interval_array(), } ) - def large_table() -> pa.Table: # Important: the order of these columns cannot change return pa.table( diff --git a/tests/rust-arrow-ffi/Cargo.lock b/tests/rust-arrow-ffi/Cargo.lock index 15350ef..7991443 100644 --- a/tests/rust-arrow-ffi/Cargo.lock +++ b/tests/rust-arrow-ffi/Cargo.lock @@ -4,13 +4,15 @@ version = 3 [[package]] name = "ahash" -version = "0.7.6" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ + "cfg-if", "getrandom", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -27,9 +29,9 @@ checksum = "bf7d0a018de4f6aa429b9d33d69edf69072b1c5b1cb8d3e4a5f7ef898fc3eb76" [[package]] name = "arrow-format" -version = "0.7.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8df5d25bc6d676271277120c41ef28760fe0a9f070677a58db621c0f983f9c20" +checksum = "07884ea216994cdc32a2d5f8274a8bee979cfe90274b83f86f440866ee3132c7" dependencies = [ "planus", "serde", @@ -37,9 +39,9 @@ dependencies = [ [[package]] name = "arrow2" -version = "0.13.1" +version = "0.17.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc54f0b14083abaf6bc71cf1aeccd7831a24b1e29d07683ba9a4a0f6c5d9326" +checksum = "59c468daea140b747d781a1da9f7db5f0a8e6636d4af20cc539e43d05b0604fa" dependencies = [ "ahash", "arrow-format", @@ -47,9 +49,12 @@ dependencies = [ "chrono", "dyn-clone", "either", + "ethnum", "foreign_vec", + "getrandom", "hash_hasher", "num-traits", + "rustc_version", "simdutf8", ] @@ -119,9 +124,15 @@ checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "either" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "ethnum" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b90ca2580b73ab6a1f724b76ca11ab632df820fd6040c336200d2c1df7b3c82c" [[package]] name = "foreign_vec" @@ -136,8 +147,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -193,9 +206,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.60" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -220,12 +233,27 @@ dependencies = [ "wasm-bindgen-test", ] +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "scoped-tls" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" + [[package]] name = "serde" version = "1.0.164" @@ -254,9 +282,9 @@ checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" [[package]] name = "syn" -version = "2.0.18" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -400,3 +428,23 @@ dependencies = [ "js-sys", "wasm-bindgen", ] + +[[package]] +name = "zerocopy" +version = "0.7.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d6f15f7ade05d2a4935e34a457b936c23dc70a05cc1d97133dc99e7a3fe0f0e" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbbad221e3f78500350ecbd7dfa4e63ef945c05f4c61cb7f4d3f84cd0bba649b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/tests/rust-arrow-ffi/Cargo.toml b/tests/rust-arrow-ffi/Cargo.toml index 07728a4..cbe16be 100644 --- a/tests/rust-arrow-ffi/Cargo.toml +++ b/tests/rust-arrow-ffi/Cargo.toml @@ -17,7 +17,7 @@ wasm-bindgen = "0.2.63" # all the `std::fmt` and `std::panicking` infrastructure, so isn't great for # code size when deploying. console_error_panic_hook = "0.1.6" -arrow2 = { version = "0.13.1", features = ["io_ipc"] } +arrow2 = { version = "0.17.4", features = ["io_ipc"] } thiserror = "1.0" [dev-dependencies] diff --git a/tests/table.arrow b/tests/table.arrow index e27717e..e607b80 100644 Binary files a/tests/table.arrow and b/tests/table.arrow differ