Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: type mismatch when creating record #730

Open
jordanrfrazier opened this issue Aug 31, 2023 · 2 comments
Open

bug: type mismatch when creating record #730

jordanrfrazier opened this issue Aug 31, 2023 · 2 comments
Labels
bug Something isn't working sparrow

Comments

@jordanrfrazier
Copy link
Collaborator

jordanrfrazier commented Aug 31, 2023

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 jordanrfrazier added bug Something isn't working sparrow labels Aug 31, 2023
@bjchambers
Copy link
Collaborator

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...

@jordanrfrazier
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sparrow
Projects
None yet
Development

No branches or pull requests

2 participants