Protryon / klickhouse

Rust crate for accessing Clickhouse
Apache License 2.0
93 stars 21 forks source link

Nullable<Bool> not being treated as Option<bool> #11

Closed Swoorup closed 1 year ago

Swoorup commented 1 year ago
/*
create table trade_event (
    symbol LowCardinality(FixedString(16)),
    exchange_id LowCardinality(String),
    trade_id UInt64,
    ts DateTime64(6),
    received_ts DateTime64(6),
    is_buyer_maker Nullable(Bool),
    price Decimal64(6),
    size Decimal64(6)
) 
engine = MergeTree()
partition by ts
order by (symbol, exchange_id, ts);
*/

#[derive(Row, Debug, Default)]
pub struct TradeEvent {
  symbol: String,
  exchange_id: String,
  trade_id: u64,
  ts: DateTime64<6>,
  received_ts: DateTime64<6>,
  is_buyer_maker: Option<bool>,
  price: FixedPoint64<6>,
  size: FixedPoint64<6>,
}

Reading the row this currently gives the following error:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: DeserializeErrorWithColumn("is_buyer_maker", "unexpected type: Int8")',

EDIT: Looks like not just option, its without as well.

Protryon commented 1 year ago

Update to klickhouse 0.7.4 which has a hotfix for supporting Clickhouse < 22 bools. Clickhouse changes the internal data format which made it glitch out, and this library was updated to Clickhouse 22.