-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Example that shows how to convert query result into rust struct #2959 #2969
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2969 +/- ##
==========================================
- Coverage 85.71% 85.71% -0.01%
==========================================
Files 280 280
Lines 51313 51313
==========================================
- Hits 43983 43982 -1
- Misses 7330 7331 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. |
Fixed all the stuff mentioned by the tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it out -- and it looks great to me.
cargo run --example deserialize_to_struct
...
+---------+------------+
| int_col | double_col |
+---------+------------+
| 0 | 0 |
| 1 | 10.1 |
| 0 | 0 |
| 1 | 10.1 |
| 0 | 0 |
| 1 | 10.1 |
| 0 | 0 |
| 1 | 10.1 |
+---------+------------+
[
Data {
int_col: 0,
double_col: 0.0,
},
Data {
int_col: 1,
double_col: 10.1,
},
Data {
int_col: 0,
double_col: 0.0,
},
Data {
int_col: 1,
double_col: 10.1,
},
Data {
int_col: 0,
double_col: 0.0,
},
Data {
int_col: 1,
double_col: 10.1,
},
Data {
int_col: 0,
double_col: 0.0,
},
Data {
int_col: 1,
double_col: 10.1,
},
]
👍
Thanks @thomas-k-cameron
use datafusion::prelude::*; | ||
use serde::Deserialize; | ||
|
||
/// This example shows that it is possible to convert query results into Rust structs . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
df.collect().await? | ||
}; | ||
// converts it to serde_json type and then convert that into Rust type | ||
let list = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 this is very cool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool example! @thomas-k-cameron
Benchmark runs are scheduled for baseline = 884101e and contender = e47c4eb. e47c4eb is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Which issue does this PR close?
Closes #2959 .
Rationale for this change
Add an example that shows how to convert query result into rust struct.
Details/Background in the issue.
What changes are included in this PR?
New example.
Are there any user-facing changes?
No.