kaskada icon indicating copy to clipboard operation
kaskada copied to clipboard

bug: type mismatch when creating record

Open jordanrfrazier opened this issue 1 year ago • 2 comments

When creating a record and casting the types inside to i64, I get an error saying it expected i64 but got i32.

Test:


#[tokio::test]
async fn test_lt_interval() {
    insta::assert_snapshot!(QueryFixture::new("
        let time = time_of(Times)
        let lag_time = time_of(Times) | lag(1)
        let days_between = days_between(time, lag_time)
        let months_between = months_between(time, lag_time)
        in { d: days_between as i64, m : months_between as i64 }
     ").run_to_csv(&timestamp_ns_data_fixture().await).await.unwrap(), @r###"
    _time,_subsort,_key_hash,_key,m,n,lt
    "###);
}

Error:

thread 'comparison_tests::test_lt_interval' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidArgumentError("Incorrect datatype for StructArray field \"m\", expected Int64 got Int32")', /Users/jordan.frazier/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arrow-array-43.0.0/src/array/struct_array.rs:90:46

Notes:

  • Using as i32 instead of as i64 works as expected.
  • You can do (x as i32) as i64
  • Without the cast, it produces the display format of durations (which is why for human-readable format we want the cast)

jordanrfrazier avatar Aug 31 '23 17:08 jordanrfrazier

Which one is x in x as i32? I believe that one of those only supports casting to i32, but I could be wrong. It's weird how the error is being reported against the struct though...

bjchambers avatar Aug 31 '23 22:08 bjchambers

Which one is x in x as i32? I believe that one of those only supports casting to i32, but I could be wrong. It's weird how the error is being reported against the struct though...

Either can use as i32 to correctly produce output.

jordanrfrazier avatar Sep 06 '23 16:09 jordanrfrazier