lquerel / gcp-bigquery-client

GCP BigQuery Client (Rust)
Apache License 2.0
92 stars 60 forks source link

Add get_serde for types that implement Deserialize #60

Closed andyquinterom closed 1 year ago

andyquinterom commented 1 year ago

This PR adds a method to allow users to get a column by index or by name for any type that implements serde::de::DeserializeOwned. This is helpful as it opens up many new types to the crate.

For example:

If a user whats to get dates with chrono they can use:

result.get_serde::<NaiveDate>(col_index);

When the type is not able to be parsed errors show the type_resquested as follows:

Err(InvalidColumnType { col_index: 1, col_type: "String", type_requested: "bigdecimal::BigDecimal" })
lquerel commented 1 year ago

Thanks for this contribution. The PR sounds reasonable for me. I will merge and publish a new version soon.