-
Notifications
You must be signed in to change notification settings - Fork 129
Description
Describe the bug
Each time calling clickhouse::Client.insert,
I always encountered the error Cannot read all data. But, when I execute an insert test in the clickhouse CLI, it works, so I suspect it might be an issue with the Rust ClickHouse client.
I suspect that it might be caused by Option
with default. In fact ,this column owns default value, so it dont need to be Nullable
, but it seems that clickhouse-rs could not resolve this.
No matter inserting None, or serde with skip_serializing_if = "Option::is_none", it does not work. And we do need this value while selecting from table.
Steps to reproduce
- Setup schema
Create table with default value col: created_at DateTime DEFAULT now()
- Define the data struct
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(with = "clickhouse::serde::chrono::datetime::option")]
created_at: Option<DateTime<Utc>>,
- Insert
pub async fn insert(usr_stat: &UsrStat, state: &State) -> Result<()> {
let mut insert = state.client.insert(USR_STAT_TABLE)?;
insert.write(usr_stat).await?;
insert.end().await?;
Ok(())
}
Error log
Error: Clickhouse(BadResponse("Code: 33. DB::Exception: Cannot read all data. Bytes read: 5. Bytes expected: 8.: (at row 1)\n: While executing BinaryRowInputFormat. (CANNOT_READ_ALL_DATA) (version 25.6.5.41 (official build))"))
Configuration
Environment
- Client version: 0.13.3
- OS: WSL Debian 12.9 on Windows11 24H2 (It works on localhost web sql )
ClickHouse server
- ClickHouse Server version: 25.6.5.41