-
Notifications
You must be signed in to change notification settings - Fork 189
Add PreparedInsert flow #443
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: master
Are you sure you want to change the base?
Conversation
| if (chtype->GetCode() == Type::LowCardinality) { | ||
| chtype = col->As<ColumnLowCardinality>()->GetNestedType(); | ||
| } |
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'm honestly not sure this is the right thing to do. Might one need Type::LowCardonality?
|
|
||
| void FinishInsert(); | ||
|
|
||
| void SendData(const Block& block); |
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 had to move this to public so that PreparedInsert can call it. Not in the header file, though, so shouldn't matter.
| public: | ||
| Block * GetBlock(); | ||
| void Execute(); | ||
| // XXX This shouldn't be public. |
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 couldn't figure out how to make this private. Suggestions appreciated.
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.
Would be nice if it worked declared public in the .cpp file, but I think I could also use an Impl class like Client does to hide such things.
ade33f4 to
51d8216
Compare
Add a new pattern for "prepared inserts". It works like this:
* Call `PrepareInsert` with an `INSERT` query with optional columns
and ending in `VALUES`. No values should be included in the string.
* It returns a `PreparedInsert` object that has two methods:
* `Block()` returns a `Block` pre-configured with columns as
declared in the `INSERT` statement
* `Execute()` inserts data from the block then clears it.
* Call `Finish()` or just let the `PreparedInsert` object go out of
scope to send any remaining rows and to signal the server that it's
done.
This allows one to send smaller batches of blocks, thereby using less
memory, but still in a single ClickHouse `INSERT` operation.
Expected to be useful in the Postgres foreign data wrapper insert API,
where multiple rows can be inserted at once but its API handles
one-at-a-time insertion. It will also support the FDW COPY API, which
can submit huge batches of data to insert, as well.
Add a new pattern for "prepared inserts". It works like this:
PrepareInsertwith anINSERTquery with optional columns and ending inVALUES. No values should be included in the string.PreparedInsertobject that has two methods:Block()returns aBlockpre-configured with columns as declared in theINSERTstatementExecute()inserts data from the block then clears it.PreparedInsertobject goes out of scope it first signals the server that it's done sending data.This allows one to send smaller batches of blocks, thereby using less memory, but still in a single ClickHouse
INSERToperation.Expected to be useful in the Postgres foreign data wrapper insert API, where multiple rows can be inserted at once but its API handles one-at-a-time insertion. It will also support the FDW COPY API, which can submit huge batches of data to insert, as well.