ClickHouse / clickhouse-rs

Official pure Rust typed client for ClickHouse DB
https://clickhouse.com
Apache License 2.0
283 stars 84 forks source link

how to support map? #101

Open strive-run opened 7 months ago

strive-run commented 7 months ago

image

ck table columns: image

and rust struct : image

when execute insert, error: thread 'main' panicked at /Users/gao.wei.strive/.cargo/registry/src/rsproxy.cn-0dccff568467c15b/clickhouse-0.11.6/src/rowbinary/ser.rs:168:9: not yet implemented

please help me , thanks.

caibirdme commented 2 months ago

+1, same problem

loyd commented 1 month ago

The documentation is not precise enough. It literally means "serialize as Array((K, V))", so you can use Vec<(String, String)> and so on here.

What's Map, serialize_map, and (most important!) Value in your example?

loyd commented 1 month ago

It's possible to support real maps (HashMap, BTreeMap, IndexMap etc) directly without using &[tuple], but it opens a large space for bugs because of #[serde(flatten)], serde_value::Value and other things which all should be handled correctly (or it ends with a lot of issues because of schema mismatch), that's not trivial.