Comments (11)
Hope this feature can be supported. If you don't have time, I can write a PR for that.
from duckdb-rs.
And please add some tests to the new features, feel free to support one type a time
from duckdb-rs.
I think struct/enums/unions would likely need some kind of derivation support via proc macros. This is an interesting example for clickhouse client where the author modified serde to enable support for struct <-> row mapping. See klickhouse_derive
https://github.com/Protryon/klickhouse
from duckdb-rs.
Would be great if we could also be able to retrieve SRUCT, MAP, ENUMs and UNION along with being able to insert them. I think the insert just needs string representation vs the retrieval needs to be convert from arrow format?
Am I correct @wangfenjin ?
from duckdb-rs.
Correct.
- If you want to support bind struct or other type as params, you may need to update bind_params
- If you want to support parse sql result as rust native datatypes like map, you may need to update get
- If it's a new native datatypes, you need to impl the FromSql and ToSql trait, example serde_json
- You may also want to add new type to enum Value when necessary, if you do that compiler will teach you multiple related places that also need to updated
from duckdb-rs.
Correct.
1. If you want to support bind struct or other type as params, you may need to update [bind_params](https://github.com/wangfenjin/duckdb-rs/blob/d2f611f922792ec6943a4f65301c81e247864fc0/src/statement.rs#L414) 2. If you want to support parse sql result as rust native datatypes like map, you may need to update [get](https://github.com/wangfenjin/duckdb-rs/blob/d2f611f922792ec6943a4f65301c81e247864fc0/src/row.rs#L544) 3. If it's a new native datatypes, you need to impl the FromSql and ToSql trait, example [serde_json](https://github.com/wangfenjin/duckdb-rs/blob/d2f611f922792ec6943a4f65301c81e247864fc0/src/types/serde_json.rs#L8-L27) 4. You may also want to add new type to enum [Value](https://github.com/wangfenjin/duckdb-rs/blob/d2f611f922792ec6943a4f65301c81e247864fc0/src/types/value.rs#L10) when necessary, if you do that compiler will teach you multiple related places that also need to updated
@wangfenjin If I try like in point 3, it says (edited out the error; I just had to add the relevant features).
Could you show an example, please, of how I can insert a String (valid JSON String) or a Vec<u8>
containing a valid JSON String?
If I try, I only see the new row as bytes (hex bytes shown in decimal for each character, and not a string).
I created the table beforehand with create table tab (col1 STRING)
. Even tried the type TEXT and JSON.
All just get inserted as bytes.
Even with the serde_json example, I still see only bytes in decimal inserted into the table.
Will duckdb-rs add native support for Rust data types (struct/enum at least)?
from duckdb-rs.
Havenโt been supported in rust yet
from duckdb-rs.
@wangfenjin appreciate your work! Just want to insert here that missing insert of lists is a deal breaker for my projects. Hope to see that implemented soon. Cheers!
from duckdb-rs.
Recent support for Union types too. ๐๐ผ Natural fits with Rust's enum.
from duckdb-rs.
@neverchanje it'll be great if you can help. Thanks
from duckdb-rs.
The overall idea is in order to make it easier for users, we need to implement the convert logic of from/to sql. After doing this, you will be more familiar with the rust API and also the C API
from duckdb-rs.
Related Issues (20)
- u64 not being casted to UBigInt and being casted to BigInt instead HOT 1
- Feature request - support Timestamp data types in the appender api
- column_count can panic
- Assertion failed: types == input.GetTypes() in column_data_collection.cpp, line 718
- impl Drop for Appender has unnecessary unsafe calls.
- Listing tables in rust never iterates HOT 2
- duckdb-rs 0.10.0 compilation failed on windows 11
- duckdb-rs 0.10 is failing on macOS Venture (13.5.2) with code 14 HOT 2
- `DataStruct.struct_vector(i).child(j)` leads to assertion failure
- No support for `UHUGEINT` (`u128`) in `FromSql` trait HOT 2
- Proper way of creating a static connection pool with r2d2 HOT 2
- The latest rust crate build for MacOS fails with default settings HOT 1
- Compared to sqlite, query execution speed is several times slower in rust code HOT 13
- BUG: Panic on `SELECT * FROM arrow(?, ?)` when using `TimestampMillisecondArray` arrow type. HOT 5
- Segfault when using `appender` with Generated Columns
- Question: If an INSERT statement includes a RETURNING Clause, how can I retrieve the returned content? HOT 4
- Support for Decimal128 & Decimal256 without downcasting to f64 HOT 5
- update link to param types in rust client api
- Pivot not working with prepared statements HOT 1
- Segmentation fault on `try_clone` misuse HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from duckdb-rs.