-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for async insert #66
base: master
Are you sure you want to change the base?
Conversation
465b1cf has fixed a issue with serializing
This happened because
|
Thanks a lot for this. I've used it to ingest fairly large datasets ~200m+ rows |
that's awesome, thank you! I hope it gets merged soon |
Sorry for the late answer. Async inserts are a nice feature and have become production-ready to have API for them. And suggested PR looks great. However, I have ambivalent feelings about it. It's simply options and can be provided by
Have you tried to use |
Does use clickhouse::{Client, Row};
use serde::Serialize;
#[tokio::main]
async fn main() {
let client = Client::default()
.with_url("http://localhost:8123")
.with_user("user")
.with_password("password")
.with_database("mydb")
.with_option("async_insert", "1")
.with_option("wait_for_async_insert", "1");
#[derive(Debug, Row, Serialize)]
struct MyRow {
user_id: u32,
message: String,
}
let mut insert = client.insert("my_table").unwrap();
insert
.write(&MyRow {
user_id: 2,
message: "I am 2".to_string(),
})
.await
.unwrap();
insert.end().await.unwrap();
} and the query actually performed doesn't seem to contain
While by using my patch: use clickhouse::{AsyncInsertOptions, Client, Row};
use serde::Serialize;
#[tokio::main]
async fn main() {
let client = Client::default()
.with_url("http://localhost:22222")
.with_user("user")
.with_password("password")
.with_database("deploy");
#[derive(Debug, Row, Serialize)]
struct MyRow {
user_id: u32,
message: String,
}
let opts = AsyncInsertOptions::builder()
.async_insert(true)
.wait_for_async_insert(true)
.build();
let mut insert = client.async_insert("my_table", opts).unwrap();
insert
.write(&MyRow {
user_id: 3,
message: "I am 3".to_string(),
})
.await
.unwrap();
insert.end().await.unwrap();
} the performed query does include
Also, I'd prefer not to make async_insert settings configured via There is a conflict in one file, and if there's a chance of getting my patch to be merged I'd be happy to address this conflict :) |
3e0ca8c
to
d92234e
Compare
@loyd Resolved the conflict and it's now ready for review again. Could I get your review and opinion on whether you think this is a right direction? Thanks. |
Closes #65
This patch adds a support for asynchronous inserts.
In order not to break public interface, a new method named
async_insert
is added toClient
, instead of fixing the existinginsert
method.This is my first patch to this repo, so please let me know if there's anything I can improve to make it more consistent with the existing code base. Thanks!