Skip to content

Commit 116d847

Browse files
committed
Merge remote-tracking branch 'origin/main' into rbwnat-insert
2 parents dc6145b + 466b873 commit 116d847

File tree

24 files changed

+346
-1168
lines changed

24 files changed

+346
-1168
lines changed

.docker/clickhouse/single_node/config.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<tmp_path>/var/lib/clickhouse/tmp/</tmp_path>
1515
<user_files_path>/var/lib/clickhouse/user_files/</user_files_path>
1616
<access_control_path>/var/lib/clickhouse/access/</access_control_path>
17+
<keep_alive_timeout>3</keep_alive_timeout>
1718

1819
<logger>
1920
<level>debug</level>
@@ -30,4 +31,15 @@
3031
<partition_by>toYYYYMM(event_date)</partition_by>
3132
<flush_interval_milliseconds>1000</flush_interval_milliseconds>
3233
</query_log>
34+
35+
<!-- required after 25.1+ -->
36+
<format_schema_path>/var/lib/clickhouse/format_schemas/</format_schema_path>
37+
<user_directories>
38+
<users_xml>
39+
<path>users.xml</path>
40+
</users_xml>
41+
</user_directories>
42+
43+
<!-- Avoid SERVER_OVERLOADED running many parallel tests after 25.5+ -->
44+
<os_cpu_busy_time_threshold>1000000000000000000</os_cpu_busy_time_threshold>
3345
</clickhouse>

CHANGELOG.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [Unreleased] - ReleaseDate
1010

11-
### Breaking Changes
11+
### Removed
1212

13-
- query: `RowBinaryWithNamesAndTypes` is now used by default for query results. This may cause panics if the row struct
14-
definition does not match the database schema. Use `Client::with_validation(false)` to revert to the previous behavior
15-
which uses plain `RowBinary` format for fetching rows. ([#221])
13+
- **BREAKING** watch: `Client::watch()` API is removed ([#245]).
14+
- **BREAKING** mock: `watch()` and `watch_only_events()` are removed ([#245]).
15+
16+
### Changed
17+
18+
- **BREAKING** query: `RowBinaryWithNamesAndTypes` is now used by default for query results. This may cause panics if
19+
the row struct definition does not match the database schema. Use `Client::with_validation(false)` to revert to the
20+
previous behavior which uses plain `RowBinary` format for fetching rows. ([#221])
21+
- **BREAKING** mock: when using `test-util` feature, it is now required to use `Client::with_mock(&mock)` to set up the
22+
mock server, so it properly handles the response format and automatically disables parsing
23+
`RowBinaryWithNamesAndTypes` header parsing and validation. Additionally, it is not required to call `with_url`
24+
explicitly. See the [updated example](./examples/mock.rs).
1625
- query: due to `RowBinaryWithNamesAndTypes` format usage, there might be an impact on fetch performance, which largely
17-
depends on how the dataset is defined. If you experience performance issues, consider disabling validation by using
26+
depends on how the dataset is defined. If you notice decreased performance, consider disabling validation by using
1827
`Client::with_validation(false)`.
19-
- mock: when using `test-util` feature, it is now required to use `Client::with_mock(&mock)` to set up the mock server,
20-
so it properly handles the response format and automatically disables parsing `RowBinaryWithNamesAndTypes` header
21-
parsing and validation. Additionally, it is not required to call `with_url` explicitly.
22-
See the [updated example](./examples/mock.rs).
28+
- serde: it is now possible to deserialize Map ClickHouse type into `HashMap<K, V>` (or `BTreeMap`, `IndexMap`,
29+
`DashMap`, etc.).
2330

2431
### Added
2532

@@ -31,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3138
functions and utilities to parse the types out of the ClickHouse server response. ([#221]).
3239

3340
[#221]: https://github.com/ClickHouse/clickhouse-rs/pull/221
41+
[#245]: https://github.com/ClickHouse/clickhouse-rs/pull/245
3442

3543
## [0.13.3] - 2025-05-29
3644
### Added

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ default = ["lz4"]
8282

8383
test-util = ["hyper/server"]
8484
inserter = ["dep:quanta"]
85-
watch = ["dep:sha-1", "dep:serde_json", "serde/derive"]
8685
uuid = ["dep:uuid"]
8786
time = ["dep:time"]
8887
lz4 = ["dep:lz4_flex", "dep:cityhash-rs"]
@@ -134,8 +133,6 @@ futures = "0.3.5"
134133
futures-channel = "0.3.30"
135134
static_assertions = "1.1"
136135
sealed = "0.6"
137-
sha-1 = { version = "0.10", optional = true }
138-
serde_json = { version = "1.0.68", optional = true }
139136
lz4_flex = { version = "0.11.3", default-features = false, features = [
140137
"std",
141138
], optional = true }

README.md

Lines changed: 53 additions & 131 deletions
Large diffs are not rendered by default.

docker-compose.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
name: clickhouse-rs
22
services:
33
clickhouse:
4-
image: 'clickhouse/clickhouse-server:${CLICKHOUSE_VERSION-24.10-alpine}'
5-
container_name: clickhouse-rs-clickhouse-server
4+
image: 'clickhouse/clickhouse-server:${CLICKHOUSE_VERSION-latest-alpine}'
5+
container_name: 'clickhouse-rs-clickhouse-server'
6+
environment:
7+
CLICKHOUSE_SKIP_USER_SETUP: 1
68
ports:
79
- '8123:8123'
810
- '9000:9000'

examples/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ If something is missing, or you found a mistake in one of these examples, please
88

99
### General usage
1010

11-
- [usage.rs](usage.rs) - creating tables, executing other DDLs, inserting the data, and selecting it back. Additionally, it covers `WATCH` queries. Optional cargo features: `inserter`, `watch`.
11+
- [usage.rs](usage.rs) - creating tables, executing other DDLs, inserting the data, and selecting it back. Optional cargo features: `inserter`.
1212
- [mock.rs](mock.rs) - writing tests with `mock` feature. Cargo features: requires `test-util`.
1313
- [inserter.rs](inserter.rs) - using the client-side batching via the `inserter` feature. Cargo features: requires `inserter`.
1414
- [async_insert.rs](async_insert.rs) - using the server-side batching via the [asynchronous inserts](https://clickhouse.com/docs/en/optimize/asynchronous-inserts) ClickHouse feature
@@ -57,7 +57,7 @@ cargo run --package clickhouse --example async_insert
5757
If a particular example requires a cargo feature, you could run it as follows:
5858

5959
```sh
60-
cargo run --package clickhouse --example usage --features inserter watch
60+
cargo run --package clickhouse --example usage --features inserter
6161
```
6262

6363
Additionally, the individual examples should be runnable via the IDE such as CLion or RustRover.

examples/mock.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,6 @@ async fn make_insert(client: &Client, data: &[SomeRow]) -> Result<()> {
2626
insert.end().await
2727
}
2828

29-
#[cfg(feature = "watch")]
30-
async fn make_watch(client: &Client) -> Result<(u64, SomeRow)> {
31-
client
32-
.watch("SELECT max(no) no FROM test")
33-
.fetch_one::<SomeRow>()
34-
.await
35-
}
36-
37-
#[cfg(feature = "watch")]
38-
async fn make_watch_only_events(client: &Client) -> Result<u64> {
39-
client
40-
.watch("SELECT max(no) no FROM test")
41-
.only_events()
42-
.fetch_one()
43-
.await
44-
}
45-
4629
#[tokio::main]
4730
async fn main() {
4831
let mock = test::Mock::new();
@@ -71,23 +54,4 @@ async fn main() {
7154
make_insert(&client, &list).await.unwrap();
7255
let rows: Vec<SomeRow> = recording.collect().await;
7356
assert_eq!(rows, list);
74-
75-
// How to test WATCH.
76-
#[cfg(feature = "watch")]
77-
{
78-
// Check `CREATE LIVE VIEW` (for `watch(query)` case only).
79-
let recording = mock.add(test::handlers::record_ddl());
80-
mock.add(test::handlers::watch(list.into_iter().map(|row| (42, row))));
81-
let (version, row) = make_watch(&client).await.unwrap();
82-
assert!(recording.query().await.contains("CREATE LIVE VIEW"));
83-
assert_eq!(version, 42);
84-
assert_eq!(row, SomeRow { no: 1 });
85-
86-
// `EVENTS`.
87-
let recording = mock.add(test::handlers::record_ddl());
88-
mock.add(test::handlers::watch_only_events(3..5));
89-
let version = make_watch_only_events(&client).await.unwrap();
90-
assert!(recording.query().await.contains("CREATE LIVE VIEW"));
91-
assert_eq!(version, 3);
92-
}
9357
}

examples/usage.rs

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async fn ddl(client: &Client) -> Result<()> {
2929
}
3030

3131
async fn insert(client: &Client) -> Result<()> {
32-
let mut insert = client.insert("some").await?;
32+
let mut insert = client.insert("some")?;
3333
for i in 0..1000 {
3434
insert.write(&MyRow { no: i, name: "foo" }).await?;
3535
}
@@ -42,12 +42,12 @@ async fn insert(client: &Client) -> Result<()> {
4242
#[cfg(feature = "inserter")]
4343
async fn inserter(client: &Client) -> Result<()> {
4444
let mut inserter = client
45-
.inserter("some")
45+
.inserter("some")?
4646
.with_max_rows(100_000)
4747
.with_period(Some(std::time::Duration::from_secs(15)));
4848

4949
for i in 0..1000 {
50-
inserter.write(&MyRow { no: i, name: "foo" }).await?;
50+
inserter.write(&MyRow { no: i, name: "foo" })?;
5151
inserter.commit().await?;
5252
}
5353

@@ -107,39 +107,6 @@ async fn select_count(client: &Client) -> Result<()> {
107107
Ok(())
108108
}
109109

110-
#[cfg(feature = "watch")]
111-
async fn watch(client: &Client) -> Result<()> {
112-
let mut cursor = client
113-
.watch("SELECT max(no) no, argMax(name, some.no) name FROM some")
114-
.fetch::<MyRow<'_>>()?;
115-
116-
let (version, row) = cursor.next().await?.unwrap();
117-
println!("version={version}, row={row:?}");
118-
119-
let mut insert = client.insert("some").await?;
120-
let row = MyRow {
121-
no: row.no + 1,
122-
name: "bar",
123-
};
124-
insert.write(&row).await?;
125-
insert.end().await?;
126-
127-
let (version, row) = cursor.next().await?.unwrap();
128-
println!("version={version}, row={row:?}");
129-
130-
// Or you can request only events without data.
131-
let mut cursor = client
132-
// It's possible to specify a view name.
133-
.watch("lv_f2ac5347c013c5b9a6c1aab7192dd97c2748daa0")
134-
.limit(10)
135-
.only_events()
136-
.fetch()?;
137-
138-
println!("{:?}", cursor.next().await);
139-
140-
Ok(())
141-
}
142-
143110
#[tokio::main]
144111
async fn main() -> Result<()> {
145112
let client = Client::default().with_url("http://localhost:8123");
@@ -153,8 +120,6 @@ async fn main() -> Result<()> {
153120
fetch_all(&client).await?;
154121
delete(&client).await?;
155122
select_count(&client).await?;
156-
#[cfg(feature = "watch")]
157-
watch(&client).await?;
158123

159124
Ok(())
160125
}

rustfmt.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
edition = "2021"
22
merge_derives = false
3-
imports_granularity = "Crate"
4-
normalize_comments = true
5-
reorder_impl_items = true
6-
wrap_comments = true

src/bytes_ext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl BytesExt {
2929
self.cursor = self.bytes.len() - n;
3030
}
3131

32-
#[cfg(any(test, feature = "lz4", feature = "watch"))]
32+
#[cfg(any(test, feature = "lz4"))]
3333
#[inline(always)]
3434
pub(crate) fn advance(&mut self, n: usize) {
3535
debug_assert!(n <= self.remaining());

0 commit comments

Comments
 (0)