-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Vectorized][Feature] Support mysql external table insert into stm #7979
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
Conversation
HappenLee
left a comment
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.
some problem need to change
| #include "vec/sink/vtablet_sink.h" | ||
|
|
||
| #include "vec/sink/vmysql_table_writer.h" | ||
| namespace doris { |
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.
add space
| int num_columns = _vec_output_expr_ctxs.size(); | ||
|
|
||
| for (int i = 0; i < num_columns; ++i) { | ||
| auto column_ptr = block.get_by_position(i).column->convert_to_full_column_if_const(); |
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.
do convert before call insert_row
|
|
||
| for (int i = 0; i < num_columns; ++i) { | ||
| auto column_ptr = block.get_by_position(i).column->convert_to_full_column_if_const(); | ||
| auto type_ptr = block.get_by_position(i).type; |
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.
do not copy
| switch (_vec_output_expr_ctxs[i]->root()->result_type()) { | ||
| case TYPE_BOOLEAN: { | ||
| auto& data = assert_cast<const vectorized::ColumnUInt8&>(*column).get_data(); | ||
| fmt::format_to(_insert_stmt_buffer, "{}", std::to_string(data[row])); |
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.
do not call to_string
| case TYPE_VARCHAR: { | ||
| const auto& string_val = | ||
| assert_cast<const vectorized::ColumnString&>(*column).get_data_at(row); | ||
| if (string_val.data == nullptr) { |
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.
DCHECK not nullptr
| fmt::format_to(_insert_stmt_buffer, "{}", "NULL"); | ||
| } | ||
| } else { | ||
| char* buf = new char[2 * string_val.size + 1]; |
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.
unique_ptr
|
|
||
| // Insert this to MySQL server | ||
| std::string insert_stmt = to_string(_insert_stmt_buffer); | ||
| LOG(INFO) << insert_stmt; |
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.
do not log each insert query
| fmt::format_to(_insert_stmt_buffer, "{}", ")"); | ||
|
|
||
| // Insert this to MySQL server | ||
| std::string insert_stmt = to_string(_insert_stmt_buffer); |
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.
try to reduce the mem alloc
| RETURN_IF_ERROR(DataSink::prepare(state)); | ||
| // Prepare the exprs to run. | ||
| RETURN_IF_ERROR(VExpr::prepare(_output_expr_ctxs, state, _row_desc, _mem_tracker)); | ||
| std::stringstream title; |
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.
use format to replace stringstream
be/src/runtime/mysql_table_writer.h
Outdated
|
|
||
| #include "common/status.h" | ||
|
|
||
| #include <fmt/format.h> |
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.
move to 21line up
HappenLee
left a comment
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.
LGTM
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
Proposed changes
Issue Number: close #7978
Problem Summary:
Describe the overview of changes.
Checklist(Required)
Further comments
If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...