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

How to deserialize RecordBatch #3

Closed
slinkydeveloper opened this issue Apr 19, 2024 · 7 comments
Closed

How to deserialize RecordBatch #3

slinkydeveloper opened this issue Apr 19, 2024 · 7 comments

Comments

@slinkydeveloper
Copy link
Contributor

Hi,
I'm trying to use your library to deserialize a RecordBatch, could you add an example for that?

Thank you!

@Swoorup
Copy link
Owner

Swoorup commented Apr 19, 2024

@slinkydeveloper

You can't directly deserialize from a RecordBatch, you'll have to convert it to a StructArray first using StructArray::from(record_batch)

@slinkydeveloper
Copy link
Contributor Author

Tried this:

#[derive(Debug, Clone, PartialEq, ArrowField, ArrowSerialize, ArrowDeserialize)]
pub struct QueryResult {
    #[arrow_field(type = "arrow_convert::field::LargeString")]
    key: String,
    #[arrow_field(type = "arrow_convert::field::LargeBinary")]
    value: Vec<u8>,
}

arrow_array_deserialize_iterator::<QueryResult>(&StructArray::from(batch)).unwrap()

But got:

called `Result::unwrap()` on an `Err` value: InvalidArgumentError("Data type mismatch")

Would be nice to have more info in this error :)

@slinkydeveloper
Copy link
Contributor Author

Interesting, for my query i managed to get it working by making all the fields optional.

#[derive(Debug, Clone, PartialEq, ArrowField, ArrowSerialize, ArrowDeserialize)]
pub struct QueryResult {
    key: Option<String>,
    value: Option<Vec<u8>>,
}

Perhaps the problem is that if in my schema a field is nullable, then the field must be optional?

@Swoorup
Copy link
Owner

Swoorup commented Apr 19, 2024

You probably have the Nullable flag enabled in one or more of your incoming data type.

Would certainly be nice to have more in-depth error reporting.

@slinkydeveloper
Copy link
Contributor Author

Would certainly be nice to have more in-depth error reporting.

Will try to PR a little change to that error message :)

@slinkydeveloper
Copy link
Contributor Author

See #4

@Swoorup
Copy link
Owner

Swoorup commented Apr 21, 2024

Published 0.6.6

@Swoorup Swoorup closed this as completed Apr 21, 2024
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

No branches or pull requests

2 participants