Skip to content

Commit

Permalink
move check to delete handler
Browse files Browse the repository at this point in the history
  • Loading branch information
TangSiyang2001 committed Oct 24, 2023
1 parent e8c11cb commit 34a30bf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
22 changes: 22 additions & 0 deletions be/src/olap/delete_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include "common/config.h"
#include "common/logging.h"
#include "common/status.h"
#include "olap/block_column_predicate.h"
#include "olap/column_predicate.h"
#include "olap/olap_common.h"
Expand Down Expand Up @@ -249,6 +250,27 @@ Status DeleteHandler::check_condition_valid(const TabletSchema& schema, const TC
}
}

if (!cond.__isset.column_unique_id) {
LOG(WARNING) << "column=" << cond.column_name
<< " in predicate does not have uid, table id=" << schema.table_id();
// TODO(tsy): make it fail here after FE forbidding hard-link-schema-change
return Status::OK();
}
if (schema.columns()[0].unique_id() < 0) {
const auto& err_msg =
fmt::format("column id does not exists in table={}, schema version={},",
schema.table_id(), schema.schema_version());
return Status::Error<DELETE_INVALID_CONDITION>(err_msg);
}
if (!iequal(schema.column_by_uid(cond.column_unique_id).name(), cond.column_name)) {
const auto& err_msg = fmt::format(
"colum name={} does not belongs to column uid={}, which column name={}, "
"delete_cond.column_name ={}",
cond.column_name, cond.column_unique_id,
schema.column_by_uid(cond.column_unique_id).name(), cond.column_name);
return Status::Error<DELETE_INVALID_CONDITION>(err_msg);
}

return Status::OK();
}

Expand Down
25 changes: 0 additions & 25 deletions be/src/olap/push_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,31 +141,6 @@ Status PushHandler::_do_streaming_ingestion(TabletSharedPtr tablet, const TPushR
DeletePredicatePB del_pred;
TabletSchema tablet_schema;
tablet_schema.copy_from(*tablet->tablet_schema());
for (const auto& delete_cond : request.delete_conditions) {
if (!delete_cond.__isset.column_unique_id) {
LOG(WARNING) << "column=" << delete_cond.column_name
<< " in predicate does not have uid, table id="
<< tablet_schema.table_id();
// TODO(tsy): make it fail here after FE forbidding hard-link-schema-change
continue;
}
if (tablet_schema.columns()[0].unique_id() < 0) {
const auto& err_msg =
fmt::format("column id does not exists in tablet={}, schema version={},",
tablet->tablet_id(), tablet_schema.schema_version());
return Status::Aborted(err_msg);
}
if (!iequal(tablet_schema.column_by_uid(delete_cond.column_unique_id).name(),
delete_cond.column_name)) {
const auto& err_msg = fmt::format(
"colum name={} does not belongs to column uid={}, which column name={}, "
"delete_cond.column_name ={}",
delete_cond.column_name, delete_cond.column_unique_id,
tablet_schema.column_by_uid(delete_cond.column_unique_id).name(),
delete_cond.column_name);
return Status::Aborted(err_msg);
}
}
if (!request.columns_desc.empty() && request.columns_desc[0].col_unique_id >= 0) {
tablet_schema.clear_columns();
for (const auto& column_desc : request.columns_desc) {
Expand Down
1 change: 1 addition & 0 deletions be/src/olap/tablet_schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ void TabletSchema::copy_from(const TabletSchema& tablet_schema) {
TabletSchemaPB tablet_schema_pb;
tablet_schema.to_schema_pb(&tablet_schema_pb);
init_from_pb(tablet_schema_pb);
_table_id = tablet_schema.table_id();
}

std::string TabletSchema::to_key() const {
Expand Down

0 comments on commit 34a30bf

Please sign in to comment.