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

Problem with stmt.query_arrow([])?.collect() #87

Closed
sspaeti opened this issue Oct 9, 2022 · 7 comments
Closed

Problem with stmt.query_arrow([])?.collect() #87

sspaeti opened this issue Oct 9, 2022 · 7 comments

Comments

@sspaeti
Copy link

sspaeti commented Oct 9, 2022

I'm a total starter and trying to learn Rust with DuckDB. Just close if it's too basic of a question, just posting it here in case others have trouble getting started.

Error:

rustc: a value of type `Vec<RecordBatch>` cannot be built from an iterator over elements of type `arrow::record_batch::RecordBatch` the trait `FromIterator<arrow::record_batch::RecordBatch>` is not implemented for `Vec<RecordBatch>`

Question: What am I doing wrong:
image

I understand the rust iterator does not like the arrow RecordBatch. But how can I fix that, did I use the wrong arrow dependencies in my Cargo.toml on the right?

@wangfenjin
Copy link
Collaborator

why depends on duckdb 0.1 version but libduckdb-sys 0.5.1 ? suggest to always use the same version, and latest version which is 0.5.1.

0.1 version duckdb doesn't support arrow

@sspaeti
Copy link
Author

sspaeti commented Oct 9, 2022

Thank you so much for your kind answer. OK now I see, I updated to the latest 0.5.1, but still has the same error.

Which Cargo.toml should be used for the simple example on the left? Should that work with the right dependencies, or should I follow something like this https://github.com/wangfenjin/duckdb-rs/blob/main/Cargo.toml?

@wangfenjin
Copy link
Collaborator

Refer to #88 , the readme example should works fine. You can try run the example in command line with cargo. Not sure what's the problem with your code editor

@sspaeti
Copy link
Author

sspaeti commented Oct 12, 2022

Didn't really manage to make it work, but I used some part of this https://github.com/hotg-ai/weld-studio/blob/7121cbffbbe7dd4ee703b1dd8b3be89daee1f857/src-tauri/src/sql.rs and removed let rbs: Vec<RecordBatch> = stmt.query_arrow([])?.collect();.

Now I have managed to have a working starting point. Thanks so much; I will close.

@sspaeti sspaeti closed this as completed Oct 12, 2022
@wangfenjin
Copy link
Collaborator

Hi @sspaeti

I checked the issue again. The arrow version in your project's Cargo.toml should be same as the version in duckdb (latest one is version 23) . Otherwise it may report error.

Sorry for the inconvenience.

@wangfenjin wangfenjin reopened this Oct 22, 2022
@snth
Copy link
Contributor

snth commented Oct 23, 2022

I ran into this problem a lot as well and the rustc error message isn't very helpful in this case and doesn't actually tell you what the problem is, i.e. it has nothing to do with an iterator and is actually just a version mismatch between different versions of arrow.

This would be helped a lot by #92 .

@sspaeti
Copy link
Author

sspaeti commented Oct 23, 2022

Excellent, thanks so much, you both. The example of Readme with the arrow version 23 worked!

For anyone else, this is my Cargo.toml:

[package]
name = "duckdb-playground"
version = "0.1.0"
edition = "2021"

[dependencies.duckdb]
version = "0.5.1"
features = ["bundled"]

[dependencies]
libduckdb-sys = "0.5.1"
arrow = { version = "23", features = ["prettyprint", "ffi"] }

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

3 participants