Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.9k
[opt](partial update) use a separate config to control the behavior of newly inserted rows in partial update#41232
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -35,12 +35,14 @@ namespace doris { | ||
| Status PartialUpdateInfo::init(int64_t tablet_id, int64_t txn_id, const TabletSchema& tablet_schema, | ||
| UniqueKeyUpdateModePB unique_key_update_mode, | ||
| PartialUpdateNewRowPolicyPB policy, | ||
| const std::set<std::string>& partial_update_cols, | ||
| bool is_strict_mode, int64_t timestamp_ms, int32_t nano_seconds, | ||
| const std::string& timezone, | ||
| const std::string& auto_increment_column, | ||
| int32_t sequence_map_col_uid, int64_t cur_max_version) { | ||
| partial_update_mode = unique_key_update_mode; | ||
| partial_update_new_key_policy = policy; | ||
| partial_update_input_columns = partial_update_cols; | ||
| max_version_in_flush_phase = cur_max_version; | ||
| sequence_map_col_unqiue_id = sequence_map_col_uid; | ||
| @@ -97,6 +99,7 @@ Status PartialUpdateInfo::init(int64_t tablet_id, int64_t txn_id, const TabletSc | ||
| void PartialUpdateInfo::to_pb(PartialUpdateInfoPB* partial_update_info_pb) const { | ||
| partial_update_info_pb->set_partial_update_mode(partial_update_mode); | ||
| partial_update_info_pb->set_partial_update_new_key_policy(partial_update_new_key_policy); | ||
| partial_update_info_pb->set_max_version_in_flush_phase(max_version_in_flush_phase); | ||
| for (const auto& col : partial_update_input_columns) { | ||
| partial_update_info_pb->add_partial_update_input_columns(col); | ||
| @@ -133,6 +136,9 @@ void PartialUpdateInfo::from_pb(PartialUpdateInfoPB* partial_update_info_pb) { | ||
| } else { | ||
| partial_update_mode = partial_update_info_pb->partial_update_mode(); | ||
| } | ||
| if (partial_update_info_pb->has_partial_update_new_key_policy()) { | ||
| partial_update_new_key_policy = partial_update_info_pb->partial_update_new_key_policy(); | ||
| } | ||
| max_version_in_flush_phase = partial_update_info_pb->has_max_version_in_flush_phase() | ||
| ? partial_update_info_pb->max_version_in_flush_phase() | ||
| : -1; | ||
| @@ -186,56 +192,55 @@ std::string PartialUpdateInfo::summary() const { | ||
| max_version_in_flush_phase); | ||
| } | ||
| Status PartialUpdateInfo::handle_not_found_error_for_fixed_partial_update( | ||
| const TabletSchema& tablet_schema) const { | ||
| if (!can_insert_new_rows_in_partial_update) { | ||
| std::string error_column; | ||
| for (auto cid : missing_cids) { | ||
| const TabletColumn& col = tablet_schema.column(cid); | ||
| if (!col.has_default_value() && !col.is_nullable() && | ||
| !(tablet_schema.auto_increment_column() == col.name())) { | ||
| error_column = col.name(); | ||
| break; | ||
| Status PartialUpdateInfo::handle_new_key(const TabletSchema& tablet_schema, | ||
bobhan1 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| const std::function<std::string()>& line, | ||
| BitmapValue* skip_bitmap) { | ||
| switch (partial_update_new_key_policy) { | ||
| case doris::PartialUpdateNewRowPolicyPB::APPEND: { | ||
| if (partial_update_mode == UniqueKeyUpdateModePB::UPDATE_FIXED_COLUMNS) { | ||
| if (!can_insert_new_rows_in_partial_update) { | ||
| std::string error_column; | ||
| for (auto cid : missing_cids) { | ||
| const TabletColumn& col = tablet_schema.column(cid); | ||
| if (!col.has_default_value() && !col.is_nullable() && | ||
| !(tablet_schema.auto_increment_column() == col.name())) { | ||
| error_column = col.name(); | ||
| break; | ||
| } | ||
| } | ||
| return Status::Error<ErrorCode::INVALID_SCHEMA, false>( | ||
| "the unmentioned column `{}` should have default value or be nullable " | ||
| "for newly inserted rows in non-strict mode partial update", | ||
| error_column); | ||
| } | ||
| } else if (partial_update_mode == UniqueKeyUpdateModePB::UPDATE_FLEXIBLE_COLUMNS) { | ||
| DCHECK(skip_bitmap != nullptr); | ||
| bool can_insert_new_row {true}; | ||
| std::string error_column; | ||
| for (auto cid : missing_cids) { | ||
| const TabletColumn& col = tablet_schema.column(cid); | ||
| if (skip_bitmap->contains(col.unique_id()) && !col.has_default_value() && | ||
| !col.is_nullable() && col.is_auto_increment()) { | ||
| error_column = col.name(); | ||
| can_insert_new_row = false; | ||
| break; | ||
| } | ||
| } | ||
| if (!can_insert_new_row) { | ||
| return Status::Error<ErrorCode::INVALID_SCHEMA, false>( | ||
| "the unmentioned column `{}` should have default value or be " | ||
| "nullable for newly inserted rows in non-strict mode flexible partial " | ||
| "update", | ||
| error_column); | ||
| } | ||
| } | ||
| return Status::Error<ErrorCode::INVALID_SCHEMA, false>( | ||
| "the unmentioned column `{}` should have default value or be nullable " | ||
| "for newly inserted rows in non-strict mode partial update", | ||
| error_column); | ||
| } | ||
| return Status::OK(); | ||
| } | ||
| Status PartialUpdateInfo::handle_not_found_error_for_flexible_partial_update( | ||
| const TabletSchema& tablet_schema, BitmapValue* skip_bitmap) const { | ||
| DCHECK(skip_bitmap != nullptr); | ||
| bool can_insert_new_rows_in_partial_update = true; | ||
| std::string error_column; | ||
| for (auto cid : missing_cids) { | ||
| const TabletColumn& col = tablet_schema.column(cid); | ||
| if (skip_bitmap->contains(col.unique_id()) && !col.has_default_value() && | ||
| !col.is_nullable() && col.is_auto_increment()) { | ||
| error_column = col.name(); | ||
| can_insert_new_rows_in_partial_update = false; | ||
| break; | ||
| } | ||
| } | ||
| if (!can_insert_new_rows_in_partial_update) { | ||
| return Status::Error<ErrorCode::INVALID_SCHEMA, false>( | ||
| "the unmentioned column `{}` should have default value or be " | ||
| "nullable for newly inserted rows in non-strict mode flexible partial update", | ||
| error_column); | ||
| } | ||
| return Status::OK(); | ||
| } | ||
| Status PartialUpdateInfo::handle_non_strict_mode_not_found_error(const TabletSchema& tablet_schema, | ||
| BitmapValue* skip_bitmap) const { | ||
| if (partial_update_mode == UniqueKeyUpdateModePB::UPDATE_FIXED_COLUMNS) { | ||
| RETURN_IF_ERROR(handle_not_found_error_for_fixed_partial_update(tablet_schema)); | ||
| } else if (partial_update_mode == UniqueKeyUpdateModePB::UPDATE_FLEXIBLE_COLUMNS) { | ||
| RETURN_IF_ERROR( | ||
| handle_not_found_error_for_flexible_partial_update(tablet_schema, skip_bitmap)); | ||
| } break; | ||
| case doris::PartialUpdateNewRowPolicyPB::ERROR: { | ||
| return Status::Error<ErrorCode::NEW_ROWS_IN_PARTIAL_UPDATE, false>( | ||
| "Can't append new rows in partial update when partial_update_new_key_behavior is " | ||
| "ERROR. Row with key=[{}] is not in table.", | ||
| line()); | ||
| } break; | ||
| } | ||
| return Status::OK(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -19,6 +19,7 @@ | ||
| #include <gen_cpp/olap_file.pb.h> | ||
bobhan1 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| #include <cstdint> | ||
| #include <functional> | ||
| #include <map> | ||
| #include <set> | ||
| #include <string> | ||
| @@ -43,19 +44,16 @@ class BitmapValue; | ||
| struct PartialUpdateInfo { | ||
| Status init(int64_t tablet_id, int64_t txn_id, const TabletSchema& tablet_schema, | ||
| UniqueKeyUpdateModePB unique_key_update_mode, | ||
| UniqueKeyUpdateModePB unique_key_update_mode, PartialUpdateNewRowPolicyPB policy, | ||
| const std::set<std::string>& partial_update_cols, bool is_strict_mode, | ||
| int64_t timestamp_ms, int32_t nano_seconds, const std::string& timezone, | ||
| const std::string& auto_increment_column, int32_t sequence_map_col_uid = -1, | ||
| int64_t cur_max_version = -1); | ||
| void to_pb(PartialUpdateInfoPB* partial_update_info) const; | ||
| void from_pb(PartialUpdateInfoPB* partial_update_info); | ||
| Status handle_non_strict_mode_not_found_error(const TabletSchema& tablet_schema, | ||
| BitmapValue* skip_bitmap = nullptr) const; | ||
| Status handle_not_found_error_for_fixed_partial_update(const TabletSchema& tablet_schema) const; | ||
| Status handle_not_found_error_for_flexible_partial_update(const TabletSchema& tablet_schema, | ||
| BitmapValue* skip_bitmap) const; | ||
| Status handle_new_key(const TabletSchema& tablet_schema, | ||
| const std::function<std::string()>& line, | ||
| BitmapValue* skip_bitmap = nullptr); | ||
| std::string summary() const; | ||
| std::string partial_update_mode_str() const { | ||
| @@ -84,6 +82,7 @@ struct PartialUpdateInfo { | ||
| public: | ||
| UniqueKeyUpdateModePB partial_update_mode {UniqueKeyUpdateModePB::UPSERT}; | ||
| PartialUpdateNewRowPolicyPB partial_update_new_key_policy {PartialUpdateNewRowPolicyPB::APPEND}; | ||
| int64_t max_version_in_flush_phase {-1}; | ||
| std::set<std::string> partial_update_input_columns; | ||
| std::vector<uint32_t> missing_cids; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 11 additions & 11 deletions
22 be/src/olap/rowset/segment_v2/vertical_segment_writer.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.