ClickHouse / ClickHouse/clickhouse-rs

Support for `rust_decimal::Decimal` in RowBinaryWithNamesAndTypes Deserialization

Open
#325 3 comments 0 reactions 1 assignee Claimed by @abonander View on GitHub
enhancement
Dominant language
Rust
Stars
559
Forks
173
Avg merge
1d 19h
Merged PRs (30d)
3

Description

# 💡 Support for `rust_decimal::Decimal` in RowBinaryWithNamesAndTypes Deserialization

### Summary

After upgrading from `clickhouse = 0.13.3` to `0.14.0`, direct deserialization attempt of `Decimal` columns into `rust_decimal::Decimal` no longer works.
The driver now throws:

**DeserializeAnyNotSupported**

### Environment

- **clickhouse crate:** 0.14.x
- **rust_decimal:** 1.x
- **ClickHouse server:** 24.x
- **Rust:** 1.89

---

### Example Code

```rust
#[derive(clickhouse::Row, serde::Deserialize, Debug)]
struct SpotPrice {
hour_of_day: u8,
spot_price_eur: rust_decimal::Decimal,
}

let rows = ch_client
.query("SELECT hour_of_day, spot_price_eur FROM elspotprices LIMIT 5")
.fetch_all::()
.await?;
```

If I change the field type to f32, it works correctly, but that loses precision when working with financial or energy pricing data.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.