-
Notifications
You must be signed in to change notification settings - Fork 144
feat: implement InsertFormatted
#364
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
base: main
Are you sure you want to change the base?
Conversation
| /// Any other type of statement may produce incorrect results. | ||
| /// | ||
| /// The statement is not issued until the first call to `.poll_write()`. | ||
| pub fn insert_formatted_with( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps then we need to deprecate fetch_bytes, replacing it with fetch_formatted_with for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could just be insert_bytes_with, I'm not particularly attached to the naming. I just tried to come up with something more descriptive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also prefer _formatted_with naming, so it is a good pick!
Let's just keep the naming consistent, i.e., insert_formatted_with + fetch_formatted_with both look good in combination, let's just mark fetch_bytes as deprecated for the next minor release to reduce confusion, and make fetch_formatted or fetch_formatted_with with the same exact content. Also perhaps that new method will be a good candidate to introduce (non-exaustive) enums for common formats, see #312
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this context, the _with suffix is referring to the SQL argument, but on the query side, that would have already been passed to Client::query().
I would call the new method fetch_formatted or fetch_with_format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #369 to follow up because this PR is blocking work on the ADBC driver and I want to avoid scope creep.
aa4b220 to
4495225
Compare
4495225 to
eb5f25b
Compare
477d35a to
8bb5713
Compare
8bb5713 to
f3f4c6d
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
It was confusing RustRover where it was.
be7929e to
380c032
Compare
|
Ugh, the CodeCov failure is due to 7 lines that I'm not even entirely sure how to hit: https://app.codecov.io/gh/ClickHouse/clickhouse-rs/pull/364?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=checks&utm_campaign=pr+comments&utm_term=ClickHouse We'd have to produce records fast enough to saturate the connection. There's lines I can try to cover in |
Summary
Client::insert_formatted_with()andInsertFormattedfor inserting data in a chosen format with a specified SQL query.InsertFormatteddoes not buffer data by default, allowing precise control over when the data is sent. For best performance, ensure data is sent in larger chunks or use.buffered()to getBufInsertFormattedwhich implements buffering.CompressedData::new()andInsertFormatted::send_compressed().BufInsertFormattedalso implementstokio::io::AsyncWritefor composability.AsyncWriteonInsertFormatteditself because every write would require copying to a new allocation anyway to send to the connection.closes #339
Checklist
Delete items not relevant to your PR:
Potential additions:
Client::insert_formatted(), taking a table name and format nameBytes, bypassing buffer?Insertusing this API